Advertisement 2
InterviewTime limit2sMemory limit1024 MB
Given each resident's coordinate and influence power, find the fewest residents to donate copies to so that everyone ends up with a copy.
Problem
There are residents in JOI Kingdom, numbered from to . Resident () lives at the coordinate on the real line, and its power of influence is . More than one resident may live at the same coordinate. A resident with a large power of influence has high advertising potential, but such a resident is careful about buying books.
Rie published a book on informatics. To encourage many people to buy copies, she can donate copies of the book to some residents. If she donates a copy to Resident (), Resident gets a copy. Then, among the residents who did not yet get a copy, every resident () satisfying the following condition buys a copy and gets it.
If all the residents read Rie's book, the Olympiads in Informatics will be greatly recognized. Write a program that calculates the minimum number of residents who must be donated copies so that all the residents get a copy of Rie's book.
Input
Read the following data from the standard input.
N
X_1 E_1
X_2 E_2
\vdots
X_N E_N
Output
Write one line to the standard output. The line contains the minimum number of residents who must be donated copies of Rie's book.
Constraints
- .
- ().
- ().
- All given values are integers.