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

int S[101];
int top;

void initialize(){
	top = 0;
}

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

int isFull(){
	return top >= 100;
}

void push(int x){
	if(isFull()){
		printf("error: stack full, can't push %d\n", x);
	}
	top++;
	S[top] = x;
}

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

int main(void){
	int a, c;
	int x;
	initialize();
	while((c = getchar()) != EOF){
		if(isdigit(c)){
			ungetc(c, stdin);
			scanf("%d", &x);
			push(x);
		}else{
			switch(c){
				case '+':
					push(pop()+pop());
					break;
				case '-':
					a = pop();
					push(pop()-a);
					break;
				case '*':
					push(pop()*pop());
					break;
				case '\n':
					printf("%d\n", pop());
					return 0;
				case ' ':
					break;
				default:
					printf("Invalid input.\n");
					break;
			}
		}
	}
}