import java.util.*;

class Main{
	public static void main(String args[]){
		int i;
		int stacksize = 100;
		String temp;
		int calc;
		int a,b;
		Deque<Integer> stack = new ArrayDeque<Integer>();
		String separator = System.getProperty("line.separator");
		Scanner sc1 = new Scanner(System.in);
		String str = sc1.nextLine();
		Scanner sc2 = new Scanner(str);
		sc2.useDelimiter(" ");
		
		while(sc2.hasNext()){
			temp = sc2.next();
			if(temp.equals("+")){
				calc = stack.removeFirst() + stack.removeFirst();
				stack.addFirst(calc);
			}else if(temp.equals("-")){
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			}else if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			}
		}
		System.out.println(stack.removeFirst());
	}
}
/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