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

int main() {
	stack<int>st;
	char x;
	while(cin>>x){
		if(x>='0' and x<='9') 
		st.push(x-'0');
		if(x=='+'){
			int a=st.top();
			st.pop();
			int b=st.top();
			st.pop();
			st.push(a+b);
		}
		else if(x=='-'){
			int a=st.top();
			st.pop();
			int b=st.top();
			st.pop();
			st.push(b-a);
		}
		else if(x=='*'){
			int a=st.top();
			st.pop();
			int b=st.top();
			st.pop();
			st.push(a*b);
		} 
	} cout<<st.top();
	return 0;
}