program i;
var
 s: string;
 
procedure Analyze(s: string);
var wrd: string;
  negative: boolean;
  modifier: longint;
  newnum: longint;
  total: longint;
  LastNum: longint;
begin
  if (s[length(s)]<>' ') then s:=s+' ';
  total:=0; modifier:=1; newnum:=0; 
  LastNum:=0;
  negative:=false;
  repeat
    wrd:=copy(s, 1, pos(' ', s)-1);
    delete(s,1,pos(' ',s));
    if (wrd='negative') then negative:=true;
    if (wrd='zero') then newnum:=0;
    if (wrd='one') then newnum:=1;
    if (wrd='two') then newnum:=2;
    if (wrd='three') then newnum:=3;
    if (wrd='four') then newnum:=4;
    if (wrd='five') then newnum:=5;
    if (wrd='six') then newnum:=6;
    if (wrd='seven') then newnum:=7;
    if (wrd='eight') then newnum:=8;
    if (wrd='nine') then newnum:=9;
    if (wrd='ten') then newnum:=10;
    if (wrd='eleven') then newnum:=11;
    if (wrd='twelve') then newnum:=12;
    if (wrd='thirteen') then newnum:=13;
    if (wrd='fourteen') then newnum:=14;
    if (wrd='fifteen') then newnum:=15;
    if (wrd='sixteen') then newnum:=16;
    if (wrd='seventeen') then newnum:=17;
    if (wrd='eighteen') then newnum:=18;
    if (wrd='nineteen') then newnum:=19;
    if (wrd='twenty') then newnum:=20;
    if (wrd='thirty') then newnum:=30;
    if (wrd='fourty') then newnum:=40;
    if (wrd='fifty') then newnum:=50;
    if (wrd='sixty') then newnum:=60;
    if (wrd='seventy') then newnum:=70;
    if (wrd='eighty') then newnum:=80;
    if (wrd='ninety') then newnum:=90;
    if (wrd='hundred') then newnum:=100;
    if (wrd='thousand') then newnum:=1000;
    if (wrd='million') then newnum:=1000000;
    if (LastNum=0) then
      begin
       Modifier:=NewNum;
       LastNum:=NewNum;
      end else
	if (NewNum>LastNum) then
	  begin
	    Modifier:=Modifier*NewNum;
	    LastNum:=NewNum;
	  end else
	  if (NewNum<LastNum) then
	    begin
	      Modifier:=Modifier+NewNum;
	      LastNum:=NewNum;
	    end;
  until s='';
  Total:=Total+Modifier;
  if (Negative) then Total:=0-Total;
  Writeln(Total);
end;

begin
 repeat
   readln(s);
   if (s<>'') then Analyze(s);
 until s='';
end.
  