import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{




	public static void main(String[] args){

		int len;
		String array[];

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
		String str=reader.readLine();
		array=str.split(" ");

		len=array.length;

		Stack stack=new Stack(len);
		int tmp;

		for(int i=0;i<len;i++){
			switch(array[i]){
			case"+":
				tmp=stack.pop()+stack.pop();
				stack.push(tmp);
				break;
			case"-":
				tmp=stack.pop()-stack.pop();
				stack.push(-tmp);
				break;
			case"*":
				tmp=stack.pop()*stack.pop();
				stack.push(tmp);
				break;
			default:
				tmp=Integer.parseInt(array[i]);
				stack.push(tmp);
			}//swicth

		}//for

		System.out.println(stack.pop());



		}catch(IOException e){

		}

	}//main
}

class Stack{
	int max;
	int ptr;
	int[] array;

	Stack(int capacity){//?????????????????????
		max=capacity;
		ptr=0;
		array=new int[max];
	}

	public void push(int p){
		if(ptr<=max)array[ptr++]=p;
	}//push????????????

	public int pop(){
		if(ptr>0)return array[--ptr];
		else return -1;
	}//pop????????????

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