#include int readword(char **c) { char *d=*c; while((**c) && (**c)!=' ') { (*c)++; } if(**c) { (**c)=0; (*c)++; } else *c=0; if(!strcmp(d, "negative")) return -1; if(!strcmp(d, "zero")) return 0; if(!strcmp(d, "one")) return 1; if(!strcmp(d, "two")) return 2; if(!strcmp(d, "three")) return 3; if(!strcmp(d, "four")) return 4; if(!strcmp(d, "five")) return 5; if(!strcmp(d, "six")) return 6; if(!strcmp(d, "seven")) return 7; if(!strcmp(d, "eight")) return 8; if(!strcmp(d, "nine")) return 9; if(!strcmp(d, "ten")) return 10; if(!strcmp(d, "eleven")) return 11; if(!strcmp(d, "twelve")) return 12; if(!strcmp(d, "thirteen")) return 13; if(!strcmp(d, "fourteen")) return 14; if(!strcmp(d, "fifteen")) return 15; if(!strcmp(d, "sixteen")) return 16; if(!strcmp(d, "seventeen")) return 17; if(!strcmp(d, "eighteen")) return 18; if(!strcmp(d, "nineteen")) return 19; if(!strcmp(d, "twenty")) return 20; if(!strcmp(d, "thirty")) return 30; if(!strcmp(d, "forty")) return 40; if(!strcmp(d, "fifty")) return 50; if(!strcmp(d, "sixty")) return 60; if(!strcmp(d, "seventy")) return 70; if(!strcmp(d, "eighty")) return 80; if(!strcmp(d, "ninety")) return 90; if(!strcmp(d, "hundred")) return 100; if(!strcmp(d, "thousand")) return 1000; if(!strcmp(d, "million")) return 1000000; while(1); } int main() { char str[8192]; int negative; int s1, s1000, s1000000, now, tmp; char *c; while(gets(str)) { if(!*str) break; c=str; negative=1; now=0; s1=0; s1000=0; s1000000=0; while(c) { tmp=readword(&c); if(tmp==-1) negative=-1; else if(tmp==1000) { s1000=now; now=0; } else if(tmp==1000000) { s1000000=now; now=0; } else if(tmp==100) now=now*100; else now=now+tmp; } s1=now; printf("%d\n", negative*(1000000*s1000000+1000*s1000+s1)); } return 0; }