import java.util.Scanner;

public class Main {
    private static int[] stack;
    private static int top=0;
    private static void push(int num){
        stack[++top]=num;
    }
    private static int pop(){
        return stack[top--];
    }
    public static void main(String[] args) {
        stack = new int[205];
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        for (String s : ss) {
            switch (s) {
                case "+": {
                    int b = pop();
                    int a = pop();
                    push(a + b);
                    break;
                }
                case "-": {
                    int b = pop();
                    int a = pop();
                    push(a - b);
                    break;
                }
                case "*": {
                    int b = pop();
                    int a = pop();
                    push(a * b);
                    break;
                }
                default:
                    push(Integer.parseInt(s));
                    break;
            }
        }
        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