import java.util.*;
import java.lang.*;
class Main {
  static int stacksize = 200;
  static int stackpointer = 0;
  static int [] stack = new int[stacksize];
//push
  static void push(int num){
    stack[stackpointer++] = num;
  }
  //pop
  static int pop(){
    return stack[--stackpointer];
  }
  //main
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String [] s = sc.nextLine().split("\\s+");
    for(int i = 0; i<s.length; i++){

      if(s[i].equals("+")){
        push(pop()+pop());
      }else if(s[i].equals("-")){
        push(-(pop()-pop()));
      }else if(s[i].equals("*")){
        push(pop()*pop());
      }else{
        push(Integer.valueOf(s[i]));
      }
    }
    System.out.println(pop());
  }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz