Buratino
"Oh, Dubinushka, let's heave!"
Papa Carlo has switched jobs and now works in a workshop where he spends his days hammering nails. To keep himself entertained, he has a TV running constantly in the workshop. Unfortunately, Papa Carlo's productivity is directly influenced by his mood, which depends on what's on TV at the moment. However, while he is hammering a nail, he doesn't pay attention to the TV, so his work speed is determined by what was on TV when he started hammering that nail. After finishing a nail, he always takes a glance at the TV (which naturally affects his mood), and then he can either start hammering the next nail immediately or take a short break to watch TV.
Papa Carlo begins his workday precisely at 9:00 AM. He takes a lunch break starting at 1:00 PM. If he realizes that he won't finish hammering a nail before the break, he won't start it. Similarly, he resumes work at 2:00 PM and finishes his day at 6:00 PM. This means he can start hammering a nail right at 9:00:00 AM (and similarly at 2:00:00 PM). For instance, if at 12:59:59 PM (or 5:59:59 PM) he wants to start hammering a nail and it takes him 1 second, he can finish it before lunch (or the end of the workday), but if it takes 2 seconds, he won't start.
The TV program schedule and its effect on Papa Carlo are known. The task is to create a work schedule with short breaks for Papa Carlo so that he can hammer the maximum number of nails in a workday.
Input
The input file contains the TV program schedule from 9:00:00 AM to 6:00:00 PM in the following format. The first line contains the number N — the number of TV programs during this period (1 ≤ N ≤ 32400). Each of the next N lines describes one program: first, the start time in the format HH:MM:SS (HH — two digits for hours, MM — two digits for minutes, SS — two digits for seconds). Then, after one or more spaces, the number T_i — the time in seconds that Papa Carlo will spend hammering one nail if he sees this program on TV beforehand (1 ≤ T_i ≤ 32400).
The programs are listed in chronological order. The first program always starts at 09:00:00. It can be assumed that the last program ends at 18:00:00.
Output
The first line of the output file should contain the maximum number of nails Papa Carlo can hammer in a workday.
Explanation of examples
In the first example, Papa Carlo hammers one nail every hour.
In the second example, during the first half of the day, he hammers one nail every half hour, but at 12:30:00 PM, he doesn't start hammering nails, instead waiting until 12:59:31 PM, and manages to hammer 2 nails before lunch. From 2:00 PM to 3:00 PM, 2 nails are hammered, and then one nail per hour.