#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top, S[1010];
void push(int x)
{
	S[++top] = x;
}
int pop()
{
	top--;
	return S[top + 1];
}
int main(void)
{
	int a, b;
	top = 0;
	char ch[100];

	while (scanf("%s", ch) != EOF)
	{
		/*if (ch == ' ' || ch == '\n')
			continue;*/
		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 if (ch[0] == '/')
		{
			a = pop();
			b = pop();
			push(a / b);
		}
		else
		{
			push(atoi(ch));
		}
	}
	printf("%d\n", pop());
	//system("pause");

	return 0;
}
