#include<stdio.h>
#include<stdlib.h>
char mozi[300];
int cnt=0;
int stack[100];
int sp=0;

void push(int i){
	stack[sp]=i;
	sp++;
}
int pop(){
	sp--;
	return stack[sp];
}

int main(){
	char c;
	int a1,a2,i,num;
	
	while( scanf("%s",&mozi) != EOF){
		if(mozi[0]=='+'){
			a2 = pop();a1 = pop();push(a1+a2);
		}else if(mozi[0] == '-'){
			a2 = pop();a1 = pop();push(a1-a2);
		}else if(mozi[0] == '*'){
			a2 = pop();a1 = pop();push(a1*a2);
		}else push(atoi(mozi));
		
	}
	
	printf("%d\n",pop());
	return 0;
	
}