#include <stdio.h>

int stack[1000];
int last = 0;

void pop(void)
{
	last--;
}
void push(int x)
{
	stack[last] = x;
	last++;
}
int top(void)
{
	return (stack[last - 1]);
}

int main(void)
{
	char str[1000000];
	int x;
	int i;
	int l, r;
	
	while (scanf("%s", str) == 1){
		x = 0;
		switch(str[0]){
			case '+':
				l = top();
				pop();
				r = top();
				pop();
				push(l + r);
			break;
			
			case '-':
				l = top();
				pop();
				r = top();
				pop();
				push(r - l);
			break;
			
			case '*':
				l = top();
				pop();
				r = top();
				pop();
				push(l * r);
			break;
		}
		if (str[0] != '+' && str[0] != '-' && str[0] != '*'){
			for (i = 0; str[i] != '\0'; i++){
				x = x * 10 + str[i] - '0';
			}
			push(x);
		}
	}
	
	printf("%d\n", top());
	
	return (0);
}