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

#define NUM 100

static int *s;
static int N;

void STACK(int maxN);
void push(int x);
int pop(void);

int main(void){
	char x;
	int a,b;
	int e = 0;
	
	STACK(NUM);
	
	while((x = getchar()) != EOF){
		if(isdigit(x)){
			push(x);
		}
		else{
		switch(x){		//switch?????§??´???????????????
		case '+':		//??????????????\??????????????¨???
			a = pop();	//????????????????????°?????????????????????,??????????????????????????????????????\
			b = pop();
			push(a + b);
			break;
			
		case '-':
			b = pop();
			a = pop();
			push(a - b);
			break;
			
		case '*':
			a = pop();
			b = pop();
			push(a * b);
			break;
			
		case '\n':		//Enter??§??????
			e = -1;
			break;
			
		
		default:
			break;
			
		}
		if (e == -1)break;
		}
	}
	printf("%d\n",pop());
	
	return 0;
}
	
	void STACK(int maxN){		//?????????????????????????????¢??°
		s = malloc(maxN * sizeof(int));
		N = 0;
	}
	
	void push(int x){		//push??¨??¢??°
		s[N++] = x;
	}
	
	int pop(void){		//pop??¨??¢??°
		if(N <= 0) {
			printf("stack pop error\n");
			return 0;
		}
		printf("pop %d\n",s[N-1]);
		return s[--N];
	}