import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String[] inputs = scan.nextLine().split(" ");
	int[] operands = new int[100];
	int cursol = 0;
	for (int i = 0; i < inputs.length; i++) {
	    int n = -1;
	    if (isOperator(inputs[i])) {
		int op1 = operands[cursol - 2];
		int op2 = operands[cursol - 1];
		if (inputs[i].equals("+")) {
		    n = op1 + op2;
		}
		if (inputs[i].equals("-")) {
		    n = op1 - op2;
		}
		if (inputs[i].equals("*")) {
		    n = op1 * op2;
		}
		cursol -= 2;
	    }
	    else {
		n = Integer.parseInt(inputs[i]);
	    }
	    operands[cursol++] = n;
	}
	System.out.println(operands[0]);
    }
    static boolean isOperator (String a) {
	if (a.equals("+") || a.equals("-") || a.equals("*")) {
	    return true;
	}
	return false;
    }
}
/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