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

int top=0;
int z[100];
char s[100];

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

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

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

