#include<iostream>
#include<istream>
#include<string>
using namespace std;
int top, S[200];//?????¶??????top?????¨??\?????¨??°???????????´??´?????°???S
void push(int x)
{
	 top++;
	//cout<<"top:"<<top<<endl;
	S[top] = x; //??\?????¶?????????????????°???
}
int pop()
{
	int x= S[top];//cout<<"top:"<<top<<endl;
	top--;//????????¶??????????????°?????????????????????
	return x;
}
int main()
{
	int a, b;
	top = 0;//?????????
	int i = 0;
	char s[100];
	//cout << "---";
	while (scanf("%s",s)!=EOF)
	{
               // cout<<s<<endl;
		if (s[0] == '+')
		{
			a = pop();
			//cout<<"a="<<a<<endl;
			b = pop();
			//cout<<"b="<<b<<endl;
			push(a + b);
			//cout<<"push"<<a+b<<endl;
		}
		else if (s[0] == '-')
		{
			b = pop();
			//cout<<"b="<<b<<endl;
			a = pop();
			//cout<<"a="<<a<<endl;
			push(a - b);
			//cout<<"push"<<a-b<<endl;
		}
		else if (s[0] == '*')
		{
			a = pop();
			//cout<<"a="<<a<<endl;
			b = pop();
			//cout<<"b="<<b<<endl;
			push(a*b);
			//cout<<"push"<<a*b<<endl;
		}
		else
		{
			push(atoi(s));
			//cout<<atoi(s)<<"push"<<endl;
		}
		i++;
	}
	printf("%d\n", pop());
	return 0;

}