Question
Auditorium Event Planner

A college auditorium receives N event requests. Each request has a start time and an end time. The auditorium can host only one event at a time, and an event ending at time x allows another event to start at time x.

Your task is to find the maximum number of events that can be hosted.

Input

The first line contains an integer KaTeX can only parse string typed expression — the number of event requests.

Each of the next KaTeX can only parse string typed expression lines contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the start and end time of an event.

Output

Print a single integer — the maximum number of events that can be hosted.

Example
Example 1:
Input
4

1 3
2 4
3 5
5 6
Output
3
Explanation
Events KaTeX can only parse string typed expression, KaTeX can only parse string typed expression, and KaTeX can only parse string typed expression can all be hosted.

Example 2:
Input
5

1 10
2 3
3 4
4 5
5 6
Output
4

Online