Pastries
InterviewTime limit2sMemory limit1024 MB
Find the maximum number of pastries Scrooge can eat within T seconds, starting at coordinate 0 on a line where each pastry at x_i takes t_i to eat.
Problem
Today is Scrooge's birthday.
As a gift, he received an entire table of pastries. Millionaires have little free time, so Scrooge wants to eat as many pastries as possible in seconds.
The table is an infinite line. Each pastry is placed at coordinate . Moving from pastry to pastry takes seconds. Eating pastry takes seconds. Pastries at the same point need no movement between them, but they must be eaten one at a time.
Scrooge starts at coordinate . Find the maximum number of pastries he can eat within seconds.
Input
The first line contains two integers and (, ), the number of pastries and the available time.
Each of the next lines contains two integers and (), the coordinate of the -th pastry and the time needed to eat it. The pastries are given in non-decreasing order of coordinate, that is, whenever .
Output
Print one line with the maximum number of pastries Scrooge can eat within seconds.
Hint
In the first sample, Scrooge goes from coordinate to coordinate , eats the first pastry, then moves to coordinate and eats the third pastry.