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

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

int main(){
	char c;
	int a1,a2;
	
	c = getchar();
	while(c!=EOF){
		if(c >='0' || c <='9' ){
			push(c-'0');
		}
		else if(c=='+' || c=='-' || c=='*'){
			a2 = pop();
			a1 = pop();
			if(c=='+')push(a1+a2);
			else if(c=='-')push(a1-a2);
			else if(c=='*')push(a1*a2);
		}
		c = getchar();	
	}
	
	printf("%d\n",pop());
	return 0;
	
}