import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			Deque<Integer> operando=new ArrayDeque<>();
			boolean isEOF=false;
			while(sc.hasNext()){
				String order=sc.next();
				boolean isOperator = false;
				String[] Operator= new String[3];
				Operator[0]=new String("+");
				Operator[1]=new String("*");
				Operator[2]=new String("-");
				for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				}
				//if(order.equals("EOF")) isEOF=true;
				if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				}
			}
			System.out.println(operando.pollFirst());
		}
	}
	public static int calc(int a, int b, String s){
		int ans=0;
		if(s.equals("+"))ans= a+b;
		if(s.equals("-"))ans= b-a;
		if(s.equals("*"))ans= a*b;
		return ans;
	}
}
/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