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

int top, S[1000];

void push(int v)
{
	S[++top] = v;
}

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

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