Problem C
Dating time

Our two lovebirds, Banmuon and Henho want to go on a date. However, they are afraid that their friends or families may find out. Thus, they have decided to setup their dating time using the following secret methods:
-
Banmuon will send Henho a string with format h1:m1 h2:m2 alpha where h1:m1 and h2:m2 represent some time in
-hour format. is an integer between and and is divisible by . -
Their dating time will be some time between h1:m1 and h2:m2, where the two clock hands, hour and minute, forms an angle equals to
degree.
However, there is a problem: their dating time may not be unique! Please help Banmuon and Henho figure out how many possible valid dating times there are.
Note
In this problem, we use a normal analog clock:
-
The minute hand rotates continuously. It takes
minutes to make one complete rotation (from to ). -
The hour hand rotates continuously. It takes
hours to make one complete rotation (from to ).
Input
The first line of input contains a single integer
It is guaranteed that h1:m1 is
less than or equal to h2:m2 and
Output
For each test case, print the number of instants when the
two clock hands form an angle equals to
Explanation of Sample input
In the first test case, there are
-
00:00
-
01:05 and
minute. -
02:10 and
minute. -
03:16 and
minute. -
04:21 and
minute. -
05:27 and
minute. -
06:32 and
minute. -
07:38 and
minute. -
08:43 and
minute. -
09:49 and
minute. -
10:54 and
minute.
Sample Input 1 | Sample Output 1 |
---|---|
3 00:00 23:59 0 00:00 23:59 90 18:00 18:01 180 |
22 44 1 |