#include <stdio.h>
#include <stdlib.h>
int main(void) {
	char s[1];
	int stack[100]; /* 2<= op <= 100 */
	int sp = 0;
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			stack[sp - 1] = stack[sp - 1] + stack[sp];
			sp--;
		}
		else if (s[0] == '-') {
			stack[sp - 1] = stack[sp - 1] - stack[sp];
			sp--;
		}
		else if (s[0] == '*') {
			stack[sp - 1] = stack[sp - 1] * stack[sp];
			sp--;
		}
		else {
			stack[sp] = atoi(s);
			sp++;
		}
	}
	printf("%d\n", stack[sp]);
	return 0;
}