In Nankai University, the poster board in front of Third Student Dining Hall is the most popular one among students. There are so many posters expected to be post there that the Students' Union have to arrange them to satisfy as many applicants as possible. Then Students' Union finds you are the one who can solve this problem by your programming genius. To help you to finish this job, Students' Union sets some rules as followed.
1. All posters should have the same height with the board.
2. No posters can overlay other posters. But their edges can be covered because no contents are on edges.
Every applicant wants his poster to be post as left as possible and assigns a line that his poster should be on the left side of this line. Or he will not admit Students' Union's arrangement and cancel his application.
Your task is to calculate how many posters can be post as most. The location of the left edge of board is assigned to be 0.
Input (Please use standard input, and don’t read or write files.) | |
The first line contains an integer N, the number of posters (0< N <= 800000). It is followed by N lines. Each line contains two integers: W, the width of the poster (0< W <=1000), and R, its rightmost position (0< R <2 * 106). | |
Output (Please use standard output, and don’t read or write files.) | |
The number of posters you can put on the board at most. | |
| |
Sample Input | Sample Output |
6 6 8 4 9 7 15 8 20 3 21 5 22
| 4
|