program trans; const cisla: array[1..3]of string = ('hundred','thousand','million'); do_dev: array[1..19]of string = ('one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve', 'thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen'); teen: array[1..8]of string = ('twenty','thirty','forty','fifty','sixty', 'seventy','eighty','ninety'); var s,s1: string; vys: longint; i,j,n,k,q,long,inx,pom: integer; ar,pol: array[1..9]of longint; f,minus: boolean; begin readln(s); while s<>'' do begin long:=length(s); i:=0;inx:=0;minus:=false; while (i<>long) do begin j:=pos(' ',s); if j=0 then j:=long else s[j]:='*'; if j=long then s1:=copy(s,i+1,j-i) else s1:=copy(s,i+1,j-i-1); f:=false; if s1='zero' then break; if s1='negative' then minus:=true; for k:=1 to 3 do if s1=cisla[k] then begin inc(inx); case k of 1: pol[inx]:=100; 2: pol[inx]:=1000; 3: pol[inx]:=1000000; end; f:=true; break; end; if not f then begin for k:=1 to 8 do if s1=teen[k] then begin inc(inx); pol[inx]:=(k+1)*10; f:=true; break; end; if not f then begin for k:=1 to 19 do if s1=do_dev[k] then begin inc(inx); pol[inx]:=k; f:=true; break; end; end; end; i:=j; end; if inx<>0 then begin pom:=1;n:=0;q:=0; while pom<=inx do begin inc(n); if pol[pom]<100 then begin if (pom=inx)or(pol[pom]<20) then ar[n]:=pol[pom] else if pol[pom+1]<10 then begin ar[n]:=pol[pom]+pol[pom+1]; inc(pom); end else ar[n]:=pol[pom]; end; if pol[pom]>90 then begin if pol[pom]=100 then begin if inx>=(pom+2) then begin if pol[pom+1]>100 then ar[n]:=pol[pom]*pol[pom+1] else begin if pol[pom+2]>100 then ar[n]:=pol[pom]*pol[pom+2] else ar[n]:=100; end; end else ar[n]:=100; end else ar[n]:=pol[pom]; end; inc(pom); inc(q); end; end; pom:=q; if inx=0 then writeln('0') else begin if minus then write('-'); inx:=1; vys:=0; while inx<=pom do begin if pom>=(inx+1) then vys:=vys+ar[inx]*ar[inx+1]; if inx=pom then vys:=vys+ar[inx]; inc(inx,2); end; writeln(vys); end; readln(s); end; end.