import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		StackImpl e = new Main().new StackImpl();
//		while(s.hasNext()) {
			String[] line = s.nextLine().split(" ");
			for(int i=0 ; i<line.length ; i++) {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		}
		System.out.println(e.pop());
	}

	public class StackImpl {

		int[] stack;
		int index;

		public StackImpl() {
			stack = new int[100];
			index = 0;
		}

		public void push(int value) {
			stack[index] = value;
			index++;
		}

		public int pop() {
			index--;
			int returnV = stack[index];
			stack[index] = 0;
			return returnV;
		}
	}
}
/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