On Christmas Eve, Santa faces an incredibly difficult logistical challenge: in one night, he must deliver presents to hundreds of millions of children worldwide. In order to have more time to deliver presents, Santa makes use of kids' sleeping schedules. He knows when they are sleeping and knows when they're awake, so with a careful ordering, he can come before they wake.
Specifically, there are children that Santa is delivering presents to. Each child has a bed time and wake time between which Santa must deliver their present. Santa takes one unit of time to deliver a present to a child.
Santa wants to know the maximum number of kids that he will be able to deliver presents to.
Input Specification
The first line of input contains one integer , the number of kids that Santa is planning to deliver presents to.
The next lines will each contain two integers and , the bed-time and wake time of a child.
Output Specification
The maximum number of presents that Santa will be able to deliver.
Sample Input 1
5
1 2
1 3
2 4
4 5
4 5
Sample Output 1
4
Sample Input 2
3
1 2
2 3
3 4
Sample Output 2
3
Comments