import java.util.LinkedList;
import java.util.Scanner;

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

	private static void solve() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		sc.close();

		String[] items = line.split(" ");
		Stack stack = new Stack();

		int op1;
		int op2;
		for (String item : items) {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pop());
	}
}

class Stack {
	private LinkedList<Integer> stack;
	public Stack() {
		stack = new LinkedList<Integer>();
	}
	public void push(int item) {
		stack.addLast(item);
	}
	public int pop() {
		int ret = stack.getLast();
		stack.removeLast();
		return ret;
	}
}
/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