#include<stdio.h>
#include<ctype.h>

int sp = 0;
char stack[200];
void push(int a);
int pop();

int main(void){
	char c;
	int flag=0;
	int x=0,y=0;
	
	while ((c=getchar())!='\n'){
		//printf("sp = %d\n\n",sp);
		switch(c){
			
		case ' ':
			//printf("c =  \n");
			if(flag){
				flag=0;
			}
			break;
			
		case '+':
			//printf("c = +\n");
			y=pop();
			x=pop();
			push(x+y);
			break;
			
			
		case '-':
			//printf("c = -\n");
			y=pop();
			x=pop();
			push(x-y);
			break;
			
		case '*':
			//printf("c = *\n");
			y=pop();
			x=pop();
			push(x*y);
			break;
			
		default:
			//printf("c = %d\n",c-'0');
			if(flag){
				sp--;
				push( pop() * 10 + (c-'0'));
			}else{
				push(c-'0');
				flag++;
			}
		}
		
	}
	printf("%d\n",pop());
	return 0;
}

void push(int a){
	//printf("push %d\n",a);
	stack[sp++]=a;
}

int pop(){
	//printf("pop %d\n",stack[--sp]);
	//sp++;
	return stack[--sp];
}