A babysitter charges €2 per hour between 18:00 and 21:30, and €4 per hour between 21:30 and midnight. She does not want to babysit before 18:00 nor after midnight.
Four lines, each containing an integer. The first two lines respectively indicate the hour and minutes of the starting time and the last two lines indicate the stopping time in a similar way. You may assume that the stopping time comes later than the starting time. If this is not the case, the stopping time falls during the next day.
The text invalid input if the babysitter is not available during the given interval, or the total amount earned by the babysitter otherwise.
Input:
18
45
23
15
Output:
12.5
Input:
18
45
0
15
Output:
invalid input