def parse(s):
if 'hour' in s:
tmp=s.split('hour')
return int(tmp[0])*3600000
elif ('h' in s) and ('m' in s) and (not 's' in s):
tmp=s.split('h')
tmp[1]=tmp[1].split('m')[0]
return int(tmp[0])*3600000+int(tmp[1])*60000
elif ('h' in s) and ('m' in s) and ('s' in s):
tmp=s.split('h')+['']
tmp[1],tmp[2]=tmp[1].split('m')
tmp[2]=tmp[2].split('s')[0]
return int(tmp[0])*3600000+int(tmp[1])*60000+int(tmp[2])*1000
elif 'min' in s:
tmp=s.split('min')
return int(tmp[0])*60000
elif (not 'h' in s) and ('m' in s) and ('s' in s) and (not 'ms' in s):
tmp=s.split('m')
tmp[1]=tmp[1].split('s')[0]
return int(tmp[0])*60000+int(tmp[1])*1000
elif (not 'h' in s) and (not 'm' in s) and ('s' in s) and (not '.' in s):
tmp=s.split('s')
return int(tmp[0])*1000
elif (not 'h' in s) and (not 'm' in s) and ('s' in s) and ('.' in s):
tmp=s.split('.')
tmp[1]=tmp[1].split('s')[0]
return int(tmp[0])*1000+int(tmp[1])*100
elif 'ms' in s:
tmp=s.split('ms')
return int(tmp[0])
return 0
while 1:
try:
print(parse(input()))
except:
break