program i;
var
 s: string;
 data: array[1..1000] of longint;
 ptr: integer;
  
procedure Analyze(s: string);
var wrd: string;
  negative: boolean;
  modifier: longint;
  newnum: longint;
  total: longint;
  LastNum: longint;
  Ignore: boolean;
  i: integer;
begin
  ptr:=0;
  if (s[length(s)]<>' ') then s:=s+' ';
  total:=0; modifier:=1; newnum:=0; 
  LastNum:=-1;
  ignore:=false;
  negative:=false;
  repeat
    wrd:=copy(s, 1, pos(' ', s)-1);
    delete(s,1,pos(' ',s));
    
    if (wrd='negative') then 
      begin
        negative:=true;
	continue;
      end;
    
    if (wrd='zero') then 
      begin	
        newnum:=0;
	ignore:=true;
      end;
    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='forty') 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=-1) then
      begin
       Modifier:=NewNum;
       LastNum:=NewNum;
      end else
	if (NewNum>LastNum) then  { mensi vetsi }
	  begin
	    if (not Ignore) then
	      begin
	       Modifier:=Modifier*NewNum;	       
	      end;
	      LastNum:=NewNum;
	  end else
	  if (NewNum<LastNum) then   { vetsi mensi }
	    begin
	      if (Ignore) then
	    	  Ignore:=false;
		  
	     if (LastNum>Data[Ptr]) and (Ptr>=1) then
	        begin
		 i:=ptr;
		 while (i>=1) and (data[i]<LastNum) do 
		   begin
		     Data[i]:=Data[i]*LastNum;
		     dec(i);
		   end;
		end;
	       Ptr:=Ptr+1;
	      Data[Ptr]:=Modifier;
	      Modifier:=NewNum;
	      LastNum:=NewNum;
	    end;
  until s='';
  
  i:=Ptr;
  while (i>=1) and (Data[i]<Modifier) do
    begin
      Data[i]:=Data[i]*Modifier;
      dec(i);
    end;
    
  inc(Ptr);
  data[Ptr]:=Modifier;
  

  Total:=0;
  for i:=1 to Ptr do Total:=Total+Data[i];
  if (Negative) then
    Total:=0-Total;
  Writeln(Total);
end;

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