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

