#Q8. 「一本通 1.1 练习 3」线段

「一本通 1.1 练习 3」线段

Description

There are nn segments on the number line. Select kk segments from them such that no two segments overlap. Find the maximum possible value of kk.

Input Format

The first line contains a positive integer nn;

In the following nn lines, each line contains two numbers aia_i and bib_i, describing each segment.

Output Format

Output an integer, the maximum value of kk.

Sample 1

3
0 2
2 4
1 3

2

Data Range and Hints

For 20%20\% of the data, n10n \leq 10;

For 50%50\% of the data, n103n \leq 10^3;

For 70%70\% of the data, n105n \leq 10^5;

For 100%100\% of the data, n106n \leq 10^6, 0ai<bi1060 \leq a_i \lt b_i \leq 10^6.