#include<stdio.h>
#include<stdlib.h>
void init(void);
char in[20];
int main(void){
	int i;
	int stk[200];
	int st_top;
	char x;
	st_top=0;
	for(i=0;i<200;i++){
		stk[i]=0;
	}
	init();
	i=0;
	while(1){
		scanf("%c",&x);
		if(x=='\n'){
			break;
		}
		if(x=='+'){
			stk[st_top-2]=stk[st_top-2]+stk[st_top-1];
			stk[st_top-1]=0;
			st_top--;
		}else if(x=='-'){
			stk[st_top-2]=stk[st_top-2]-stk[st_top-1];
			stk[st_top-1]=0;
			st_top--;
		}else if(x=='*'){
			stk[st_top-2]=stk[st_top-2]*stk[st_top-1];
			stk[st_top-1]=0;
			st_top--;
		}else if(x==' '){
			if(i>0){
				i=0;
				stk[st_top]=atoi(in);
				st_top++;
				init();
			}
		}else{
			in[i]=x;
			i++;
		}
	}
	printf("%d\n",stk[0]);
}
void init(void){
	int j;
	for(j=0;j<20;j++){
		in[j]=0;
	}
	return;
}