Meseryx is fed up with global warming and plans to use his creativity in the field of…
- User
Meseryx is fed up with global warming and plans to use his creativity in the field of environmental crisis; but...
Recently, the police got the news that there is going to be a terrorist attack in the city. At the moment, the terrorists are hiding in houses next to Azadi Street. Next to Azadi Street n There are n houses and at most one terrorist lives in each house.
To contain this terrorist attack and arrest the terrorists, m m The police have monitored those houses. Police i i-th houses l i l i until r i r i has monitored We know that if more than one terrorist lives in the area under the supervision of a policeman, the policemen become suspicious and arrest the terrorists.
Mesriks, who learned about this incident, thinks to himself that maybe the maximum number of terrorists who can live in these houses (without being arrested) can be an effective parameter in the environmental crisis. Then he asks you to calculate this value for him.
input In the first line of the input, two numbers in order n n and m m comes
in line i i-th of m m next line, two numbers l i l i and r i r i It is stated that it represents the range of houses that the police i i-m is watching.
1 ≤ l i ≤ r i ≤ n 1≤l i ≤r i ≤n 1 ≤ n , m ≤ 100
000 1 ≤ n, m ≤ 100 000
output Print the maximum number of terrorists that can live in these houses and not get caught on the only output line.
Example Sample entry 1 5 2 1 3 2 4 Plain text Sample output 1 3 Plain text Sample input 2 6 3 2 4 3 5 2 5 Plain text Sample output 2 3 c++
- Assistant