import java.util.*;

public class Main{
	
	public static void main(String[] args) {
		int val;
		int val2;
		int result;
		Scanner in = new Scanner(System.in);
		Stack<Integer> stack = new Stack<>();
		String expression = in.nextLine();
		String[] arr = expression.split(" ");

		for(String str : arr) {
			
			
			switch(str) {
			case "+" :
				val = stack.pop();
				val2 = stack.pop();
				stack.push(val + val2);
				break;
			case "-":
				val = stack.pop();
				val2 = stack.pop();
				stack.push(val2 - val);
				break;
			case "*":
				val = stack.pop();
				val2 = stack.pop();
				stack.push(val * val2);	
				break;
			case "/":
				val = stack.pop();
				val2 = stack.pop();
				stack.push(val2 / val);
				break;
			default:
				stack.push(Integer.parseInt(str));
				break;
			
			}
			
			
		}
		
		result = stack.pop();
		System.out.println(result);
			
	}
		
}

/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