import java.util.*;

public class Main {
	public static void main(String[] args) {
		Stack<Long> stack = new Stack<Long>();
		Scanner scanner0 = new Scanner(System.in);
		Scanner scanner = new Scanner(scanner0.nextLine());
		scanner0.close();
		
		while (scanner.hasNext()) {
			if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			}
		}
				
		scanner.close();
		
		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