#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
while (getline (cin, s)){ //字串分析
int i=0, num, sum=0, count;
while (s.length()>0){
if (isdigit(s[i]) == 0 && s[i]!='.'){ //isdigit(s[i])判斷是否為數字,s[i]!='.'忽略對點的判斷
num = atoi(s.substr (0, i).c_str()); //s.substr (0, i)把非數字字元之前的字串取出,用atoi將其轉為int
//9個時間單位判斷並把num換成毫秒灌入sum
if (s[i]=='s' && s[i-2]=='.'){
//.s
sum += num*1000;
sum += atoi(&s[i-1])*100; //字元轉int:atoi(&char)
count = 0;
}
else if (s[i]=='s'){
//s
sum += num*1000;
count = 0;
}
else if (s[i]=='m' && s[i+1]=='s'){
//ms
sum += num;
count = 2;
}
else if (s[i]=='m' && s[i+1]=='i'){
//min
sum += num*60000;
count = 2;
}
else if (s[i]=='m'){
//m
sum += num*60000;
count = 0;
}
else if (s[i+1]=='o'){
//hour
sum += num*3600000;
count = 3;
}
else {
//h
sum += num*3600000;
count = 0;
}
//再來s.erase(從第幾個開始移除,總共移除幾個)num以及其單位
s.erase(0, i+1+count); //i+1索引值從0開始的問題,count是計算單位的長度,都會少1是因為s[i]是單位的第一個字元
i=0; //重置 i 下一次就會從頭開始讀取
}
else {
i++; //繼續尋找非數字或點的字元
}
}
cout << sum << '\n';
}
return 0;
}