Stepan's Task
While sorting through his childhood toys, Stepan discovered a collection of N unique rectangles and recalled a problem his old math teacher once posed to him. We define a rectangle as small if there exists another rectangle in the set that can completely cover it. The rectangles can be rotated, but their sides must remain parallel.
For instance, a rectangle with sides 1 and 10 can be fully covered by a rectangle with sides 10 and 3, but not by a rectangle with sides 9 and 9. Rectangles with sides 10 and 3, as well as those with sides 9 and 9, cannot be covered, so in this set of three rectangles, only one is considered small. Write a program to solve the problem Stepan remembered: determine the number of small rectangles in the given set.
Input
The first line of the input contains a single integer N (2 ≤ N ≤ 200000). Each of the following N lines contains two positive integers representing the dimensions of one rectangle. All dimensions do not exceed 1000000. There are no identical rectangles in the set.
Output
The output should be a single integer representing the number of small rectangles in the given set.