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

int main(void) {
	int n[200] = { 0 };
	char stack[100];
	int top = -1;
	int temp;

	while ( scanf("%s", stack) != EOF ) {
		if (stack[0] == '+') {
			if (top > 0) {
				temp = n[top - 1] + n[top];
				top -= 1;
				n[top] = temp;
			}
		}
		else if (stack[0] == '-') {
			if (top > 0) {
				temp = n[top - 1] - n[top];
				top -= 1;
				n[top] = temp;
			}
		}		
		else if (stack[0] == '*') {
			if (top > 0) {
				temp = n[top - 1] * n[top];
				top -= 1;
				n[top] = temp;
			}
		}
		else {
			top++;
			n[top] = atoi(stack);
		}
	}

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

	return 0;
}
