program i; var s: string; p: array[0..20] of string; a, slov: integer; lastc: longint; aktc: longint; function split(x: string): integer; var i: integer; w: integer; begin for i:=0 to 20 do p[i]:=''; split:=0; w:=1; for i:=1 to length(x) do begin if x[i]<>' 'then begin p[w]:=p[w]+x[i]; end else begin w:=w+1; end; end; split:=w; end; function classfy(x: string): longint; var k: longint; begin classfy:=0; if (x='ten')then begin classfy:=10; exit; end; if (x='nine')then begin classfy:=9; exit; end; if (x='eight')then begin classfy:=8; exit; end; if (x='seven')then begin classfy:=7; exit; end; if (x='six')then begin classfy:=6; exit; end; if (x='five')then begin classfy:=5; exit; end; if (x='four')then begin classfy:=4; exit; end; if (x='three')then begin classfy:=3; exit; end; if (x='two')then begin classfy:=2; exit; end; if (x='one')then begin classfy:=1; exit; end; if (x='zero')then begin classfy:=0; exit; end; if (x='million')then begin classfy:=1000000; exit; end; if (x='thousand')then begin classfy:=1000; exit; end; if (x='hundred')then begin classfy:=100; exit; end; {if copy(x,length(x)-2,2)='ty' then} begin if (x='ninety')then begin classfy:=90; exit; end; if (x='eighty')then begin classfy:=80; exit; end; if (x='seventy')then begin classfy:=70; exit; end; if (x='sixty')then begin classfy:=60; exit; end; if (x='fifty')then begin classfy:=50; exit; end; if (x='forty')then begin classfy:=40; exit; end; if (x='thirty')then begin classfy:=30; exit; end; if (x='twenty')then begin classfy:=20; exit; end; end; { if copy(x,length(x)-4,4)='teen' then} begin if (x='nineteen')then begin classfy:=19; exit; end; if (x='eighteen')then begin classfy:=18; exit; end; if (x='seventeen')then begin classfy:=17; exit; end; if (x='sixteen')then begin classfy:=16; exit; end; if (x='fifteen')then begin classfy:=15; exit; end; if (x='fourteen')then begin classfy:=14; exit; end; if (x='thirteen')then begin classfy:=13; exit; end; end; if (x='twelve')then begin classfy:=12; exit; end; if (x='eleven')then begin classfy:=11; exit; end; end; function convert: longint; var i,j: integer; sucet: longint; pole: array[0..20]of longint; begin convert:=0; sucet:=0; lastc:=1; aktc:=1; for i:=0 to 20 do pole[i]:=0; for i:=1 to slov do begin pole[i]:=classfy(p[i]); writeln(pole[i]); end; for i:=1 to slov do begin if (pole[i]<=90) then begin if pole[i+1]=1000 then begin sucet:=sucet+pole[i]*pole[i+1]; i:=i+1; end else if pole[i+1]=1000000 then sucet:=sucet+pole[i]*pole[i+1] else if pole[i+1]=100 then begin if pole[i+3]=1000 then begin sucet:=sucet+100000*pole[i]+1000*pole[i+2]; i:=i+3; continue; end else if pole[i+3]=1000000 then begin sucet:=sucet+100000000*pole[i]+1000000*pole[i+2]; i:=i+3; continue; end else begin sucet:=sucet+pole[i]*pole[i+1]; i:=i+1; end; end else sucet:=sucet+pole[i]; end; end; convert:=sucet; end; BEGIN slov:=0; repeat readln(s); if s='' then break; slov:=split(s); writeln(convert); until s=''; END.