try:
while True:
s=input().replace("hour","*3600000+").replace("h","*3600000+").replace("min","*60000+").replace("ms","*1+").replace("m","*60000+").replace("s","*1000+")
print(int(eval(s[0:-1]))) #計算 字串0~倒數第二
except EOFError:
pass