import java.util.Scanner;
import java.util.Stack;

public class Main {

    Scanner sc = new Scanner(System.in);

    void solve() {
        // Input
        String[] rawInputs = sc.nextLine().split(" ");

        // Solve
        Stack<String> stack = new Stack<>();
        for (String input : rawInputs) {
            switch (input) {
                case "+": {
                    Integer opl = Integer.valueOf(stack.pop());
                    Integer opr = Integer.valueOf(stack.pop());
                    Integer result = opr + opl;
                    stack.push(String.valueOf(result));
                    break;
                }
                case "-": {
                    Integer opl = Integer.valueOf(stack.pop());
                    Integer opr = Integer.valueOf(stack.pop());
                    Integer result = opr - opl;
                    stack.push(String.valueOf(result));
                    break;
                }
                case "*": {
                    Integer opl = Integer.valueOf(stack.pop());
                    Integer opr = Integer.valueOf(stack.pop());
                    Integer result = opr * opl;
                    stack.push(String.valueOf(result));
                    break;
                }
                default: {
                    stack.push(input);
                }
            }
        }
        String result = stack.pop();

        // Output
        System.out.println(result);
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}


/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