#include<stdio.h>
int stack[200];
int top;
int main(){
	char item[10];
	while(scanf("%s",item)!=EOF){
		if(isNum(item)){
			instack(string2int(item));
		}else if(isSign(item)){
			int num1 = outstack();
			int num2 = outstack();
			int rst = calculate(item,num2,num1);
			instack(rst);
		}
	}
	printf("%d\n",outstack());
	return 0;
}
void instack(int num){
	stack[top] = num;
	top++;
}
int outstack(){
	top--;
	return stack[top];
}

int isNum(char item[]){
	char c = item[0];
	if(c >= '0' && c <= '9'){
		return 1;
	}
	return 0;
}
int isSign(char item[]){
	char c = item[0];
	return c=='+' || c=='-' || c=='*';
} 
int string2int(char string[]){
	int i,rst = 0,num;
	for(i=0;string[i];i++){
		num = string[i]-'0';
		rst = rst * 10;
		rst = rst + num;
	}
	return rst;
}
int calculate(char string[],int a,int b){
	switch(string[0]){
		case '+':
			return a + b;
		case '-':
			return a - b;
		case '*':
			return a * b;
		default:
			return 0;
	}
}
