import java.util.*;
import java.io.*;

public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		operateStack ost = new operateStack();
		String[] str;
		int len, top = 0;
		long op, cal;
		
		str = br.readLine().split(" ", 0);
		len = str.length;
		
		for(int i = 0; i < len; i++){
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		}
		
		System.out.println(ost.pop());
	}
}

class operateStack{
	long[] stack = new long[100];
	int top;
	
	operateStack(){
		for(int i = 0; i < 100; i++){
			stack[i] = 0;
		}
		top = 0;
	}
	
	void push(long op){
		stack[top] = op;
		top ++;
	}
	
	long pop(){
		long op = stack[top - 1];
		stack[top - 1] = 0;
		top --;
		
		return op;
	}
	
	void calc(int flag){
		long op, op2;
		long cal;
		
		op = pop();
		op2 = pop();
		
		switch(flag){
		case 1:
			cal = op2 + op;
			break;
		case 2:
			cal = op2 - op;
			break;
		default:
			cal = op2 * op;
			break;
		}
		
		push(cal);
	}
}
/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