#include <stdio.h>
#include <stdlib.h>
#define SIZE 200

int main(void) {
	int stack[SIZE];
	int t = 0;
	char elm[15];

	while (scanf("%s", elm) != EOF) {
		if (elm[0] >= '0' && elm[0] <= '9') stack[t++] = atoi(elm);
		else if (elm[0] == '+') {t--; stack[t - 1] += stack[t];}
		else if (elm[0] == '-') {t--; stack[t - 1] -= stack[t];}
		else if (elm[0] == '*') {t--; stack[t - 1] *= stack[t];}
	}

	printf("%d\n",stack[0]);

	return 0;
}