intervals

Time limit: 0.5s Memory limit: 64MB Input: Output:

Task

Alessandro is a famous juggler and everyone loves him. He was asked to organize multiple shows, and he needs some help scheduling them.

Alessandro needs to take part in NN different shows, numbered from 00 to N1N-1. Each show must be assigned a day in which he performs it.
Show ii starts at a specific time AiA_i and ends at a specific time BiB_i of its assigned day.
He has to decide the day to perform each show, note that Alessandro can decide to perform each show on a different day, so the intervals are allowed to overlap.

Alessandro can perform two shows in the same day if the first show ends exactly at the time when the second show starts. Formally, he can perform shows ii and jj on the same day if Bi=AjB_i = A_j. He can also perform three or more shows in the same day if the first show ends exactly when the second shows starts, the second show ends exactly when the third shows start, and so on. He may schedule the shows in any order.
Note that he can't perform two shows in the same day if the first show ends strictly before the second show starts and there are no shows between.

What is the minimum number of days Alessandro needs to perform every show? Note that Alessandro can always perform every show in at most NN days by assigning each show a different day.

Input

The first line contains a single integer NN (1N21051 \le N \le 2 * 10^5), the number of shows.

The following NN lines contains two integers each: AiA_i and BiB_i (0Ai<Bi1090 \le A_i < B_i \le 10^9) for each i=0N1i=0\ldots N-1.

For tests worth 2020 points, there is at most one pair of shows that can be performed in the same day.

For tests worth 3535 more points, (N1000N \le 1000) and (0Ai<Bi10000 \le A_i < B_i \le 1000).

Output

You need to write a single line with an integer: the minimum number of days Alessandro needs to perform every show.

Example 1

stdin

4
4 9
2 4
9 12
1 4

stdout

2

Example 2

stdin

5
1 5
4 5
5 8
5 9
1 9

stdout

3

Notes

In the first sample case Alessandro can perform shows 00, 22 and 33 in first day and show 11 in the second day.

In the second sample case, there are multiple solutions, all of which takes three days. For example, a possible solution is to perform shows 00 and 33 in the first day, 44 in the second day and 11 and 22 in the third day.

Log in or sign up to be able to send submissions!