import java.util.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args){
		Deque<Integer> S = new ArrayDeque<Integer>();
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] str = line.split(" ");
		for(String s : str){
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		}
		sc.close();
		System.out.println(S.getFirst().intValue());

	}

}

/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