Mr X loves his clock. His clock displays time in the HH:MM Format using the 24 hour system, the first 2 characters in the string are used to display the current hour, with possible leading zeros. Also, the last 2 characters are used to display the current minutes, also with possible leading zeroes.
Now, Mr X came up with a new thing, where he calls a particular time displayed by the clock good if the sum of all digits written on the clock during that time is divisible by a given number x.
You have been given the current time displayed by the clock and an integer x. You need to find the minimum number of minutes Mr X needs to wait, to see a good time being displayed by the clock. If the clock is already displaying a good time, Mr X does not need to wait at all.
If the clock will never ever display a good time, then print −1 instead as the answer.
Input Format:
The first line contains a string in the HH:MM format. The next line contains a single integer x.
Output Format:
Print a single integer denoting the minimum number of minutes Mr X needs to wait to see a good time being displayed by the clock, or −1 if this can never happen.
Constraints :
0≤HH<24
0≤MM<60
1≤x<20
The current time is 04:04, i.e in the morning. Now, when the clock displays the time 04:06, the sum of all digits on the clock is 0+4+0+6=10 i.e divisible by 5.
To reach this time from the current time, Mr X needs to wait a minimum of 2 minutes.