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

public class Main {

	
	public static void main(String argv[]) {

        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        String num1,num2;
        int n1,n2;
        String[] tokens = str.split(" ");
        
        Stack<String> stack = new Stack<>();
        for(int i=0; i<tokens.length; i++)
        {
        	if(tokens[i].equals("+") || tokens[i].equals("-") || tokens[i].equals("*"))
        	{
        		num2 = stack.pop();
        		num1 = stack.pop();
        		n1 = Integer.parseInt(num1);
        		n2 = Integer.parseInt(num2);
        		if(tokens[i].equals("+")) 
        		{
        			n1 = n1 + n2;
        			stack.push(Integer.toString(n1));
        		}
        		else if(tokens[i].equals("-"))
        		{
        			n1 = n1 - n2;
        			stack.push(Integer.toString(n1));
        		}
        		else if(tokens[i].equals("*"))
        		{
        			n1 = n1 * n2;
        			stack.push(Integer.toString(n1));
        		}
        	}
        	else
        	{
        		stack.push(tokens[i]);
        	}        		
        }
        
        System.out.println(stack.pop());
        in.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