#include #include #include using namespace std; map m; char s[10000]; int main() { char *c; int min,vys,mil,hun,tis; m["zero"]=0; m["one"]=1; m["two"]=2; m["three"]=3; m["four"]=4; m["five"]=5; m["six"]=6; m["seven"]=7; m["eight"]=8; m["nine"]=9; m["ten"]=10; m["eleven"]=11; m["twelve"]=12; m["thirteen"]=13; m["fourteen"]=14; m["fifteen"]=15; m["sixteen"]=16; m["seventeen"]=17; m["eighteen"]=18; m["nineteen"]=19; m["twenty"]=20; m["thirty"]=30; m["forty"]=40; m["fifty"]=50; m["sixty"]=60; m["seventy"]=70; m["eighty"]=80; m["ninety"]=90; while (gets(s)) { if (!s[0]) return 0; vys=0; mil=0; tis=0; hun=0; c=strtok(s," "); if (!strcmp(c,"negative")) { min=1; c=strtok(NULL," "); } else min=0; do { if (!strcmp(c,"million")) { mil=vys; vys=0; } else if (!strcmp(c,"thousand")) { tis=vys; vys=0; } else if (!strcmp(c,"hundred")) { vys*=100; } else vys+=m[c]; } while ((c=strtok(NULL," "))); vys+=mil*1000000+tis*1000; if (min) vys=-vys; printf("%d\n",vys); } return 0; }