import java.util.*;

public class Main {

	public static void main(String args[]) {
		Stack<Integer> myStack = new Stack<Integer>();
		
		Scanner in = new Scanner(System.in);
		String problem = in.nextLine();
		
		Scanner problemScanner = new Scanner(problem);
		
		while(problemScanner.hasNext()) {
			if(problemScanner.hasNextInt()) {
				myStack.push(problemScanner.nextInt());
			}
			else {
				String operator = problemScanner.next();
				
				int a = myStack.pop();
				int b = myStack.pop();
				
				switch(operator) {
				case "+" : myStack.push(a + b);
				break;
				case "-" : myStack.push(b - a);
				break;
				case "*" : myStack.push(b * a);
				break;
				default : break;
				}
			}
			
			
		}
		
		System.out.println(myStack.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