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

int top;

int isEmpty() {
	return ((top == 0)? 1:0);
}

void push(int *s, int x) {
	top++;
	s[top] = x;
}

int pop(int *s) {
	if (isEmpty()) {
		fprintf(stderr, "underflow\n");
	} else {
		top--;
	}

	return s[top + 1];
}

int main() {
	int x,tmp;
	int stack[100];
	char s[100];

	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			tmp = pop(stack);
			x = pop(stack) + tmp;
			push(stack,x);
		} else if (s[0] == '-') {
			tmp = pop(stack);
			x = pop(stack) - tmp;
			push(stack,x);
		} else if (s[0] == '*') {
			tmp = pop(stack);
			x = pop(stack) * tmp;
			push(stack,x);
		} else {
			x = atoi(s);
			push(stack,x);
		}
	}
	printf("%d\n", stack[top]);

	return 0;
}