#include /* TODO */ #if 0 #define dpf(x) printf x #else #define dpf(x) (void)0 #endif #define dp dpf /* value of token */ int value(char *s) { int c = *s; int d = *(s + 1); int e = *(s + 2); if (c == 'z') return 0; if (c == 'o') return 1; if (c == 't') { if (d == 'w') { if (e == 'o') return 2; /* tw? */ s += 3; e = *s; if (e == 'l') return 12; return 20; } else if (d == 'h') { if (e == 'r') return 3; if (e == 'o') return 1000; s += 5; e = *s; return e == 'e' ? 13 : 30; } else if (d == 'e') return 10; } if (c == 'f') { if (d == 'o') { if (e == 'u') return *(s + 4) == 0 ? 4 : 14; return 40; } else if (d == 'i') { if (e == 'v') return 5; return *(s + 4) == 'y' ? 50 : 15; } } if (c == 's') { if (d == 'i') { s += 3; d = *s; e = *(s + 1); if (d == 0) return 6; if (e == 'e') return 16; return 60; } else if (d == 'e') { s += 5; d = *s; e = *(s + 1); if (d == 0) return 7; if (e == 'y') return 70; return 17; } } if (c == 'e') { if (d == 'l') return 11; s += 5; d = *s; if (d == 0) return 8; if (d == 'y') return 80; return 18; } if (c == 'n') { if (d == 'e') return -1; s +=4; d = *s; e = *(s + 1); if (d == 0) return 9; if (e == 'y') return 90; return 19; } if (c == 'm') return 1000000; return 100; } int main(void) { char str[100]; char c; int x,y,neg; while (1) { if ((c = getchar()) == '\n') break; ungetc(c,stdin); c = 0; x = 0; while (c != '\n') { scanf("%[^ \n]%c",str,&c); y = value(str); dp(("got %s %d\n",str,y)); if (y == -1) { neg = 1; } else if (y >= 100) { if (x == 0) x = 1; x *= y; } else x += y; } if (neg) x = -x; printf("%d\n",x); } return 0; }