#T340. 活动选择

活动选择

Description

The school has nn events scheduled over the next few days, all of which require the use of the school auditorium. At any given time, the auditorium can only be used by one event. Due to scheduling conflicts, the school office staff has no choice but to have some events give up using the auditorium and use other classrooms instead.

Given the start time begin_ibegin\_i and end time end_iend\_i (begin_i<end_ibegin\_i < end\_i) for each of the nn events, please help the office staff arrange as many events as possible to use the auditorium.

Input Format

The first line contains an integer nn (n1000n \leq 1000);
The next nn lines each contain two integers: the first is begin_ibegin\_i, and the second is end_iend\_i (begin_i<end_i32767begin\_i < end\_i \leq 32767).

Output Format

Output the maximum number of events that can be scheduled.

11
3 5
1 4
12 14
8 12
0 6
8 11
6 10
5 7
3 8
5 9
2 13

4