import re
import sys
import time

def minutes(timestr):
    """Return number of minutes in timestr that must be either ##:## or #:##."""
    m = re.match(r"(\d?\d):(\d\d)$", timestr)
    if m is None:
       raise ValueError("Invalid timestr: %r" % (timestr,))
    h, m = map(int, m.groups())
    return 60*h + m

def minutes2(timestr):
    h, m = map(int, timestr.partition(':')[::2])
    return 60*h + m

def minutes3(timestr):
    t = time.strptime(timestr, "%H:%M")
    return 60*t.tm_hour + t.tm_min


for timestr in sys.stdin:
    timestr = timestr.rstrip('\n')
    for f in [minutes, minutes2, minutes3]:
        try:
            result = f(timestr)
        except ValueError as e:
            print("%-8s(%5r) -> error: %s" % (f.__name__, timestr, e))
        else:
            print("%-8s(%5r) -> %s" % (f.__name__, timestr, result))