#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
int top, S[200];//?????¶??????top?????¨??\?????¨??°???????????´??´?????°???S
void push(int x)
{
	 top++;
	S[top] = x; //??\?????¶?????????????????°???
}
int pop()
{ 
	int x= S[top];
	top--;//????????¶??????????????°?????????????????????
	return x;
}
int main()
{
	int a, b;
	top = 0;//?????????
	int i = 0;
	char s[100];
	//cout << "---";
	while (scanf("%s",s)!=EOF)
	{

		if (s[0] == '+')
		{
			a = pop();

			b = pop();
	
			push(a + b);
		
		}
		else if (s[0] == '-')
		{
			b = pop();
		
			a = pop();
		
			push(a - b);
		
		}
		else if (s[0] == '*')
		{
			a = pop();
		
			b = pop();
		
			push(a*b);
		
		}
		else
		{
			push(atoi(s));

		}
		i++;
	}
	printf("%d\n", pop());
	return 0;

}