import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	private static class Stack {

		private int [] data;
		private int top;

		// ????????????Stack stack = new Stack(?????????????????????);???
		public Stack(int stackSize) {
			this.data = new int[stackSize];
			this.top = 0;
		}

		// ?????????????????????????????????????????????
		// ????????????
		// stack.push(?????????);
		public void push(int pushData) {
			this.data[this.top] = pushData;
			this.top++;
		}

		// ??????????????????????????????????????????????????????
		// ????????????
		// int data = stack.pop();
		public int pop() {
			this.top--;
			int popData = this.data[this.top];

			return popData;
		}
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] formula = br.readLine().split(" ");

		Stack stack = new Stack(100);

		for(int i = 0; i < formula.length; i++) {
			if(!formula[i].equals("+") && !formula[i].equals("-") && !formula[i].equals("*")) {
				stack.push(Integer.parseInt(formula[i]));
			} else {
				if(formula[i].equals("+")) {
					int popNum1 = stack.pop();
					int popNum2 = stack.pop();

					int formulaResult = popNum2 + popNum1;

					stack.push(formulaResult);
				} else if(formula[i].equals("-")) {
					int popNum1 = stack.pop();
					int popNum2 = stack.pop();

					int formulaResult = popNum2 - popNum1;

					stack.push(formulaResult);
				} else if(formula[i].equals("*")) {
					int popNum1 = stack.pop();
					int popNum2 = stack.pop();

					int formulaResult = popNum2 * popNum1;

					stack.push(formulaResult);
				}
			}
		}
		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