#include<stdio.h>
#include<ctype.h>
int main(void) {
	char c;
	int stack[100],flag=0,top = 0;

	while ((c=getchar()) != '\n') {
		if (c >= '0'&&c <= '9') {
			if (flag) {
				stack[top] = stack[top] * 10 + (c - '0');
			}else {
				stack[top] = (c - '0');
				flag++;
			}
		}
		if (c == ' ') {
			if (flag) {
				top++;
				flag = 0;
			}
		}
		if (c == '+') {
			if (top > 1) {
				top--;
			}
			stack[top - 1] += stack[top];
			stack[top] = 0;
		}
		if (c == '-') {
			if (top > 1) {
				top--;
			}
			stack[top - 1] -= stack[top];
			stack[top] = 0;
		}
		if (c == '*') {
			if (top > 1) {
				top--;
			}
			stack[top - 1] *= stack[top];
			stack[top] = 0;
		}
	}

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

	return 0;
}
