import java.util.* ;

class Calc {
  public static void main (String [] arg) {
    Stack<Integer> stack = new Stack<Integer> () ; // Merci la librairie.
    for (int k = 0 ; k < arg.length ; k++) {
      String x = arg[k] ;
      if (x.equals("+")) {
	int i1 = stack.pop(), i2 = stack.pop() ;
	stack.push(i2+i1) ;
      } else if (x.equals("-")) {
	int i1 = stack.pop(), i2 = stack.pop() ;
	stack.push(i2-i1) ;
      } else if (x.equals("*")) {
	int i1 = stack.pop(), i2 = stack.pop() ;
	stack.push(i2*i1) ;
      } else if (x.equals("/")) {
	int i1 = stack.pop(), i2 = stack.pop() ;
	stack.push(i2/i1) ;
      } else {
	stack.push(Integer.parseInt(x)) ;
      }
      System.err.println(x + " -> " + stack) ;
    }
    System.out.println(stack.pop()) ;
  }
}
