import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

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

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        Deque<String> stack = new ArrayDeque<String>();
        String line = sc.nextLine();
        String[] a = line.split(" ");
        for (String s : a) {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        }
        System.out.println(stack.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