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

int stack[1000];
int main(void) {
	int top = 0, val;
	char buf[100], *ptr;
	while (scanf("%s", buf) != EOF) {
		val = strtol(buf, &ptr, 10);
		if (buf == ptr) {
			switch (*buf) {
				case '+': val = stack[top - 2] + stack[top - 1]; break;
				case '-': val = stack[top - 2] - stack[top - 1]; break;
				case '*': val = stack[top - 2] * stack[top - 1]; break;
			}
			stack[top - 2] = val;
			top--;
		} else {
			stack[top++] = val;
		}
	}
	printf("%d\n", *stack);
}