#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int stack[1000];
int top;
int pop()
{
	top--;
	return stack[top+1];

}
void push(int a)
{
	//top++;
	stack[++top] = a;
	return;
}
int main()
{
	char s[100];
	top = 0;
	while(scanf("%s",s) != EOF)
	{
		if(s[0]=='+')
		{
			int a = pop();
			int b = pop();
			push(a+b);
		}else if(s[0]=='-')
		{
			int a = pop();
			int b = pop();
			push(a-b);
		}else if(s[0]=='*')
		{
			int a = pop();
			int b = pop();
			push(a*b);
		}else
		{
			push(atoi(s));
			// printf("%d\n",atoi(s) );
		}
	}
	printf("%d\n",pop());
	return 0;
}