#include <string.h>
#include <stdlib.h>
#include <stdio.h>
int top;
int M[1000];
void push(int X) {
	M[++top] = X;
}
int pop() {
	top--;
	return M[top+1];
}
int main() {
	top = 0;
	int A, B;
	char s[100];
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			A = pop();
			B = pop();
			push(A + B);
		}
		else if (s[0] == '-') {
			B = pop();
			A = pop();
			push(A - B);
		}
		else if (s[0] == '*') {
			A = pop();
			B = pop();
			push(A * B);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	
	return 0;
}

