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