import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static int Oper(ArrayList<String> in) {
		String operators = "+-*/";
		Stack<String> stack = new Stack<String>();
		for (int i = 0; i < in.size(); i++) {
			if (!operators.contains(in.get(i))) {
				stack.push(in.get(i));
			} else {
				int y = Integer.parseInt(stack.pop());
				int x= Integer.parseInt(stack.pop());
				int action = operators.indexOf(in.get(i));
				if (action == 0) {
					stack.push(String.valueOf(x+y));
				} else if (action == 1) {
					stack.push(String.valueOf(x-y));
				} else if (action == 2) {
					stack.push(String.valueOf(x*y));
				} else if (action == 3) {
					stack.push(String.valueOf(x/y));
				}
			}
		}
		return Integer.parseInt(stack.pop());
		
	
	}
	public static void main(String[] args) {
		Scanner scan= new Scanner(System.in);
		ArrayList<String> ARRRAY = new ArrayList<>();
		while (scan.hasNext()) {
			ARRRAY.add(scan.next().trim());
		}
		
		System.out.println(Oper(ARRRAY));
		scan.close();
	}

}

/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