Bus Routes
In a rectangular-shaped country, the intercity highway network is straightforward. Each highway is a straight line segment running strictly north-south or west-east, connecting opposite sides of the country's border. Cities are located at some of these highway intersections, with no two cities sharing the same highway.
The country, once affluent, did not manage its budget wisely. For instance, there was a direct bus route between every pair of cities, allowing passengers to travel directly from one city to another via the shortest path without any stops.
However, during the next year's budget planning, it was discovered (as often happens) that the revenue from intercity transportation was significantly lower than the maintenance costs. Consequently, a decision was made to reduce the number of routes. To avoid public dissatisfaction due to transfers, it was decided that the travel distance between any two cities should remain minimal.
Input
The first line contains a single natural number N—the number of cities, where 2 ≤ N ≤ 10000.
The following N lines each contain two non-negative integers x_i and y_i—representing the highways at whose intersection the cities are located (x_i is the number of the north-south highway, and y_i is the number of the west-east highway).
Highways in each direction are numbered consecutively from 0 to 1000000. North-south highways are numbered from west to east, and west-east highways are numbered from north to south.
Output
The first line should contain a single integer P—the minimum number of bus routes that need to be retained.