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

int top = 0;
int stack[1000] = {0};

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

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

int main(void)
{
	int a = 0;
	int b = 0;
	char str[100] = {0};

	while (scanf("%s", str) != EOF)
	{
		if (str[0] == '+')
		{
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (str[0] == '-')
		{
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (str[0] == '*')
		{
			a = pop();
			b = pop();
			push (a * b);
		}
		else
		{
			push(atoi(str));
		}
	}

	printf("%d\n", pop());

	return 0;
}
