Simon cannot sleep

2.7

65 votes
Basic Programming, Math Basic, Basics of Implementation, C++
Problem

It's 12 o'clock at midnight (00:00) and Simon cannot sleep! So he decided to stare at the clock on his wall until he falls asleep.

He saw the clock's hands and got to thinking 'How many times they'll pass each other until I fall asleep'. Imagine that he fell asleep at hh:mm. Now, you must  figure out how many times clock's hands overlap from 00:00 to hh:mm (including 00:00 and hh:mm).

You can see an overlap in the provided picture.

Note: His clock only has an hour and minute hands.

Input format

The first and only line you will get a time in the hh:mm format.

0h23

0m59

Output format

Print the number of times that the hour and minute hands pass each other from 00:00 to hh:mm.

Sample 2

08:36

In this sample, clock's hands overlap 8 times.

Sample 3

03:16

In this sample, clock's hands overlap 3 times.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The hands pass each others only at 00:00.

Editor Image

?