M. Many CF Rounds vs Capoo
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Capoo likes Codeforces Rounds, but he is picky - he only likes to take part in rounds with difficulty no lower than his current rating.

Suppose Capoo's rating is $$$x$$$. Initially, $$$x=0$$$.

There are $$$n$$$ CF rounds. For the $$$i$$$-th round, its difficulty is $$$a_i$$$, and it has a hidden score $$$b_i$$$. One round can only be participated in once.

Capoo will participate in a round only if $$$x \leq a_i$$$. After participating, Capoo's rating will be reset to $$$\max(b_i, x)$$$.

You may freely arrange the order of the rounds. How many rounds can Capoo participate in at most?

Input

The first line contains an integer $$$n(1 \leq n \leq 10^6)$$$.

The next $$$n$$$ lines each contain two integers $$$a_i, b_i(0 \leq a_i, b_i \leq 10^{18})$$$, representing the difficulty and hidden value of the $$$i$$$-th round, respectively.

Output

A line containing an integer, representing the maximum number of CF rounds that Capoo can participate in.

Example
Input
10
19 18
6 15
5 8
4 20
18 3
16 9
0 7
5 17
2 13
15 17
Output
5