#include<stdio.h>
#include<stdlib.h>

int top, S[100];
 
void push(int x){
	top++;
	S[top]=x;
}
 
int pop(){
	top--;
	return S[top+1];
}
 
int main(void){
	int a, b, i, count;
	char s[100];
	top=0;
	
	count = 0;
	
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			b=pop();
			a=pop();
			push(a+b);
			count--;
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
			count--;
		}else if(s[0]=='*'){
			b=pop();
			a=pop();
			push(a*b);
			count--;
		}else{
			push(atoi(s));
			count++;
		}
	}
	
	/*for(i=0;i<count;i++){
		printf("%d\n", S[i]);
	}
	*/
	printf("%d\n",pop());
	
	return 0;
}