#JSUTCPC2026F. Elders are prohibited from participating in ICPC —— 老登禁止参加 ICPC

Elders are prohibited from participating in ICPC —— 老登禁止参加 ICPC

Problem Description

Among contemporary university students, there is a popular competition known as the International Chuuni Performance Contest (ICPC).

Don't be intimidated by the name. This is not a competition where you can just shout "Dark Flame Palm" and win. It's a serious (yet not too serious) event that requires creativity, expressiveness, and even a bit of "overwhelming confidence".

Timothy, a passionate young man, wants to sign up for the competition. However, when he carefully read the rules, he discovered a bolt from the blue: high school students (minors) and undergraduate graduates are not allowed to participate as official contestants. In other words, if he insists on participating, he can only play a supporting role as a "friend participant", and no matter how well he performs, he won't receive a medal.

"Then what am I doing for?" Timothy sat in front of the computer, roasting as he frantically searched for the participation conditions of various countries. Soon, he discovered a hidden trick: the age of high school graduation and university graduation varies across different countries. As long as his age is greater than or equal to the minimum age for high school graduation in a certain country, and strictly less than the minimum age for university graduation in that country, he can officially become a contestant.

So, the question arises: Timothy's actual age this year is xx years old, and he has yy ICPC competitions from around the world ahead of him. He needs to know which competitions he can actually win awards in, rather than just participating for fun.

Now, please help him calculate how many places he can go to compete for that shiny medal?

Input

The first line contains an integer x(1⩽x⩽109)x(1 \leqslant x \leqslant 10^9) representing Timothy's age. (Yes, the problem statement guarantees that he can theoretically live to be 10910^9 years old.)

The second line contains an integer yy (1⩽y⩽1051 \leqslant y \leqslant 10^5) representing the number of matches found.

Next yy lines: Each line contains two integers ai,bi(1⩽ai,bi⩽109)a_i, b_i (1 \leqslant a_i, b_i \leqslant 10^9), where aia_i represents the age of high school graduation in that country and bib_i represents the age of undergraduate graduation in that country.

Output

Output a line containing a single number, indicating the number of competitions Timothy can participate in.

Samples

20
4
18 22
21 25
16 20
19 30
2

Note

For the first example, Timothy is 20 years old. Let's look at the rules of the four countries:

  1. Country A: High school graduates are 18 years old, and undergraduate graduates are 22 years old; Timothy's age range falls within this range: 18⩽20<2218 \leqslant 20 < 22. He is eligible to participate and win a medal.
  2. Country B: High school graduation at 21 years old, undergraduate graduation at 25 years old; Timothy is one year away from turning 21, sorry, age insufficient, suggest coming back next year.
  3. Country C: High school graduation at 16 years old, undergraduate graduation at 20 years old; note that it is required to be strictly less than 20 years old, and Timothy is exactly 20 years old; one year difference, completely out of the running.
  4. Country D: High school graduate at 19 years old, undergraduate graduate at 30 years old; Timothy's age satisfies 19⩽20<3019 \leqslant 20 < 30, so he can participate and aim for a medal without any problem!

Therefore, Timothy was ultimately able to participate as a formal contestant and win awards in ICPC competitions held in two countries.