QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 192 MB Total points: 10

#10668. Map 2 [B]

統計

Jane has found an old map of her town in her basement. The map is a square-shaped piece of paper divided into unit squares on which several mysterious points are marked. Jane does not know the meaning of these points and that is why she decided to visit each one of them. She decided to meet with 3 of her colleagues - Jack, Adam and Robert - in one of points for which both map coefficients are integers: this will be the starting point. Afterwards each of the persons will be assigned an area in which he/she will find all the mysterious points and check the secrets hidden in them. Jane decided to settle four areas: the first one that consists of all the points with both coefficients less than the coefficients of the starting point, the second one in which both coefficients are greater, the third one in which the first coefficient is greater and the second one is less, and the fourth one in which the first coefficient is less and the second one is greater. In the end all the colleagues will visit together the marked points for which the first or second coefficient equals the corresponding coefficient of the starting point.

Now Jane only needs to choose the starting point. It should be chosen in such a way that each person will visit independently at least one of the mysterious points. Can you find the number of such starting points?

Input Format

The first line of the standard input contains two integers $ n $ and $ d $ ($1 ≤ n ≤ 1\,000\,000$, $3 ≤ d ≤ 10^{9}$), denoting the number of points that are marked on the map and the size of the map. The following $ d $ lines contain descriptions of the points, each of which has the form of a pair of integers $ x_{i} $, $ y_{i} $ ($0 ≤ x_{i}, y_{i} ≤ d $), representing the coefficients of the $ i $-th point. All points in the input are distinct.

Output Format

The first and only line of the standard output should contain a single integer representing the number of points that can become the starting point.

Example

Input

6 5
0 0
1 4
2 2
3 2
4 4
5 1

Output

4
problem_10668_1.gif
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.