1790 Interval Problem


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 32M

Problem types
Allowed languages
C, C++, Java, Python

Description

We call [a,b] an interval where a < b. we call [a,b] is an nested interval of [c,d] where c < a and b < d.

Here comes the problem. You are given N intervals, calculate the number of interval who is a nested interval of another.

Input

Several test case. Every case, first line an integer N(1<=N<=100000). Then N lines, two integer a,b for each line(0<=a<b<=10^9); I guarantee that in every test case, there will be no integer appear twice or more.

Output

The result.

Sample

Input

1
1 1000000000

2
5 6
2 9

5
1 10
2 9
3 8
4 7
5 6

Output

0
1
4

Source: dd


Comments

There are no comments at the moment.