#include <stdio.h>
#define MAX 10000

int initialize();
int isEmpty();
int isFull();
int push(int x);
int pop(int x);

int top=0;
int S[MAX];

int main(){
	int a,b;
	char str[MAX];
	initialize();
	while(scanf("%s",str)!=EOF){
		if(str[0]='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(str[0]='-'){
			a=pop();
			b=pop();
			push(a-b);
		}else if(str[0]='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(str));
		}
		printf("%d\n",pop());
		return 0;
	}


}

int initialize(){
	top=0;
}

int isEmpty(){
	return top==0;
}

int isFull(){
	return top >= MAX-1;
}

void push(int x){
	if(isFull()) return -1;
	top++;
	S[top]=x;
}

int pop(){
	if(isEmpty()) return -1;
	top--;
	return S[top+1];
}