#include <iostream>
#include <stack>
#include <cstdlib>
using namespace std;

stack <int> s1; 



int main(){
	int a,b;
	string s;
	
	while(cin>>s){
		if(s=="+"){
			a=s1.top();
			s1.pop();
			b=s1.top();
			s1.pop();
			s1.push(b+a);
		}
		else if(s=="-"){
			a=s1.top();
			s1.pop();
			b=s1.top();
			s1.pop();
			s1.push(b-a);
		}
		else if(s=="*"){
			a=s1.top();
			s1.pop();
			b=s1.top();
			s1.pop();
			s1.push(b*a);
		} 
		else{
			s1.push(atoi(s.c_str()));
		}
	}
	cout<<s1.top()<<endl;
} 