

import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		
		Stack<Integer> stack=new Stack<Integer>();
		
		String expression=input.nextLine();
		
		String[] arrays=expression.split(" ");
		
		for(int i=0;i<arrays.length;i++){
			if(Character.isDigit(arrays[i].charAt(0)))
				stack.add(Integer.parseInt(arrays[i]));
			else if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			}
				
		}
		
		System.out.println(stack.pop());
		
		
	}
	
	public static int add(int number1,int number2,char symbol){
		int result=0;
		if(symbol=='+')
			result=number1+number2;
		else if(symbol=='-')
			result=number1-number2;
		else if(symbol=='*')
			result=number1*number2;
		else if(symbol=='/')
			result=number1/number2;
		
		
		return result;
	}

}
/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