import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		String[] array = br.readLine().split(" ");
		Deque<String> mainDeque = new ArrayDeque<>();
		for(String str: array){
			mainDeque.offerLast(str);
		}
		Deque<Integer> intDeque = new ArrayDeque<>();
		
		while(!mainDeque.isEmpty()){
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		}
		
		System.out.println(intDeque.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