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

import static java.lang.Integer.decode;
import static java.lang.Integer.parseInt;

/**
 * Elementary data structures - Stack
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		Deque<Integer> stack = new ArrayDeque<Integer>();

		StringTokenizer st = new StringTokenizer(br.readLine());
		while (st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			}
		}
		System.out.println(stack.pop());
	} //end main
}
/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