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

int top,S[100];

int pop()
{
	top--;
	return S[top+1];
}

void push(int x)
{
	S[++top] = x;
}

int main()
{
	char ch[10];
	int a, b;
	top = 0;
	//freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    while(scanf("%s", ch) != EOF)
    {
    	if(ch[0] == '+')
    	{
			a = pop();
			b = pop();
			push(a + b); 
		}
		else if(ch[0] == '-')
		{
			a = pop();
			b = pop();
			push(b - a); 
		}
		else if(ch[0] == '*')
		{
			a = pop();
			b = pop();
			push(a * b); 
		}
		else
			push(atoi(ch));
	}
	printf("%d\n", pop());
    //printf("%lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}