Fax McClad, Croneria's most well respected bounty hunter, needs to renew his flight license. In order to do so, he will have to take a flight examination.
For the examination, Fax is required to fly straight, but he can change his altitude. In front of him, there are checkpoints: the one is located kilometers from his starting point and has an altitude of meters.
Fax can increase his altitude at a rate of up to meters per kilometer traveled and can decrease his altitude at a rate of up to meters per kilometer traveled. Fax's initial altitude is meters and he cannot go below this altitude.
Fax is able to do a special technique called the somersault. When he performs this technique, he will rise meters before going back down to his original altitude in a loop fashion. In doing so, he can go through a checkpoint that is exactly meters above him from his original altitude, if one exists.
Fax's exam ends when there are no more checkpoints in front of him. His score is determined by the number of checkpoints he passes. What is the maximum number of checkpoints that Fax can pass through?
Constraints
For 40% of the points, .
Note to Python users: It is recommended to submit in PyPy.
Input Specification
The first line of input will contain four space-separated integers: , , , and .
lines of input follow. The line will contain two space-separated integers: and , specifying the distance and the altitude of the checkpoint. It is guaranteed that all are pairwise distinct.
Output Specification
Output a single integer, the maximum number of checkpoints that Fax can pass through.
Sample Input
6 400 200 300
2 600
3 1000
3 1200
3 1300
5 700
6 200
Sample Output
4
Diagram for Sample
The black points signify the checkpoints, and the red line is the optimal path that Fax McClad can take.
Comments
Can he perform the somersault when he is not currently at a checkpoint?
Yes.