﻿var
  length, i: integer;
  stack: array of integer;
  str: string;

function isEmpty: boolean;
begin
  if(length = 0) then result := true
  else result := false;
end;

function pop(): integer;
begin
  if(not isEmpty) then 
  begin
    result := integer(stack[length - 1]);
    length -= 1;
  end
end;

procedure push(num: integer);
begin
  stack[length] := num;
  length += 1;
  setlength(stack, length + 1);
end;

begin
  length := 0;
  setlength(stack, length + 1);
  readln(str);
  for i := 1 to str.Length do
  begin
    if(str[i].IsDigit) then (push(integer(str[i]) - 48))
    else
      case str[i] of
        '+': push(pop + pop);
        '-': push(-(pop - pop));
        '*': push(pop * pop);
        '/': push(trunc(power(pop, -1) / power(pop, -1)));
      end;
  end;
  writeln(integer(stack[length - 1]));
end.