#include <iostream> #include <math.h> using namespace std; int main() { string from,to,lev; double dis; double sum=0; while(cin>>from&&from!="0"){ cin>>to; cin>>dis; cin>>lev; if(lev == "F"){ dis = 2 * dis; }else if(lev == "B"){ dis += 0.5*dis; }else if(lev == "Y"){ if(1<=dis && dis<=500) dis = 500; else if(dis > 500) dis = dis; } sum += dis; } cout<<round(sum)<<endl; } // 64 位输出请用 printf("%lld")