Interval Containing the Most Others

Time limit2sMemory limit128 MB

Problem

There are N intervals on a number line. Each endpoint of an interval is represented by one integer coordinate. Intervals may overlap, and one interval may completely contain another. However, no two intervals share an endpoint; the same coordinate is never used as an endpoint of more than one interval.

An interval [a, b] contains an interval [c, d] when a < c and d < b. Find the maximum number of other intervals that can be contained in a single interval.

      *-----------*
      |           |
*-----------*
|           |
| *-*   *-* |
| | |   | | |
1 2 3 4 5 6 7 8 9 10

In the arrangement above, the interval 1-7 contains the intervals 2-3 and 5-6, so the answer is 2.

Input

The first line contains the number of intervals N. (1 <= N <= 25,000)

Each of the next N lines contains two integers A and B describing one interval. (1 <= A < B <= 2,000,000,000)

Output

Print the maximum number of other intervals that can be contained in a single interval.