During a quest game, you need to open a door. The door has a keyboard and a small screen with 4 digit places. The door will open only if the digits shown on the screen are equal to the minutes and seconds of the correct time. Unfortunately, the keyboard is very slow, so it takes 1 second to press a key and 2 seconds to move to a different key. For example, pressing "0000" will take 4 seconds, and pressing "1212" will take 10 seconds (4 seconds for pressing keys and 3*2 = 6 seconds for moving to other keys).
You will be given the current time as "MM:SS". If the screen shows nothing when you start, return the minimum time needed to open the door.
|