CSES - Aalto Competitive Programming 2024 - wk2 - Wed - Binge watching
  • Time limit: 1.00 s
  • Memory limit: 512 MB

Maija has taken a day off from work and is going to binge watch as many movies as she can. She has listed out all the movies airing on TV today. Given the list, find the maximum number of movies she can watch from beginning to end.

Input

The first input line contains an integer n which is the number of movies.

After this, there are n lines that describe the movies. Each line has two integers a and b which are the starting and ending times of a movie.

Output

Print one integer which is the maximum number of movies.

Constraints

  • 1 \le n \le 2 \cdot 10^5
  • 1 \le a < b \le 10^9

Example

Input:

3
3 5
4 9
5 8

Output:

2