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

int main(void)
{
	int stack[100];
	int top = 0;
	int x;
	char str[100];
	while (scanf("%s", str) != EOF)
	{
		if (str[0] == '+')
		{
			stack[top - 2] = stack[top -2] + stack[top - 1];
			top--;
			continue;
		}
		if (str[0] == '-')
		{
			stack[top - 2] = stack[top -2] - stack[top - 1];
			top--;
			continue;
		}
		if (str[0] == '*')
		{
			stack[top - 2] = stack[top -2] * stack[top - 1];
			top--;
			continue;
		}
		x = atoi(str);
		stack[top] = x;
		top++;
	}

	printf("%d\n", stack[0]);
	return 0;
}
