#include <stdio.h>
int stack[100];
int it=0;
int pop(){
	return stack[it--];
}

void push(int x){
	stack[++it]=x;
}

int main(void){
	int i=0,x,y;
	char str[64];
	while(scanf("%s",str)!=EOF){
		switch(str[0]){
			case '+':
			x = pop();
			y = pop();
			push(y+x);
			break;
			case '-':
			x = pop();
			y = pop();
			push(y-x);
			break;
			case '*':
			x = pop();
			y = pop();
			push(y*x);
			break;
			case '/':
			x = pop();
			y = pop();
			push(y/x);
			break;
			default:
			push(atoi(str));
			break;
		}
	}
	printf("%d\n",pop());
	return 0;
}