LogiQuest

267. Maximum Meetings in One Room

EasyInterval Scheduling

Meetings have start and end times. A meeting can start only after the previous one ends (start > end of previous). Print the maximum number of meetings one room can host.

Input format

Line 1: n Next n lines: start end

Output format

The maximum count.

Example 1

Input

6
1 2
3 4
0 6
5 7
8 9
5 9

Output

4

Example 2

Input

3
10 20
12 25
20 30

Output

1

Constraints

1 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…