# include <stdio.h>
# include <stdlib.h>
# include <string.h>
void push(int a);
int pop();
int top;
int S[1000];
int main()
{
	top = 0;
char s[100];
	int a;
	int b;
	while(scanf("%s",s) != EOF)
	{
		switch(s[0])
		{
			case '+':	a=pop();b=pop();push(a+b);break;
			case '-':	a=pop();b=pop();push(b-a);break;
			case '*':	a=pop();b=pop();push(a*b);break;
			default :	push(atoi(s));
		}
	}
	printf("%d\n",pop());
}
void push(int a)
{
	top++;
	S[top] = a;
	
}
int pop()
{
	top -= 1;
	return S[top+1];
}
