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

int push(char x);
int pop();

int S[10000];
char c[10000];
int top = -1;
int i;

int main(void)
{
	
	while (scanf("%s", c) != EOF) {
		if (c[0] >= '0' && c[0] <= '9') {
			push(c[0] - '0');
		}
		else {
			if (c[0] == '+') {
				S[top] = S[top - 1] + S[top];
			}
			else if (c[0] == '-') {
				S[top] = S[top - 1] - S[top];
			}
			else if (c[0] == '*') {
				S[top] = S[top - 1] * S[top];
			}
		}
	}
	
	printf("%d\n", S[top]);
	
	return (0);
}

int push(char x)
{
	top++;
	S[top] = x;
	return (0);
}

int pop()
{
	top--;
	printf("top = %d", top);
	return (S[top + 1]);
}