#include <stdio.h>

void push(int);
int pop(void);

int list[100], top = 0;

int main(){
	int a, b;
	char str[6];
	
	while(1){
		if(scanf("%s", str) == EOF) break;
		if(str[0] == '+'){
			a = pop();
			b = pop();
			push(a+b);
		}
		else if(str[0] == '-'){
			a = pop();
			b = pop();
			push(a-b);
		}
		else if(str[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		}
		else push(atoi(str));
	}
	
	printf("%d\n", list[top]);
	
	return 0;
}

void push(int x){
	top++;
	list[top] = x;
}

int pop(void){
	if(top == 0) exit(1);
	top--;
	return list[top+1];
}