#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#define N 200

int A[N];
int top;

void initialize(){
	top = 0;
}

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

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

void push(int a){
	if(isFull()){
		printf("error\n");
	}else{
		top++;
		A[top] = a;
	}
}

char pop(){
	if(isEmpty()){
		printf("error\n");
	}else{
		top--;
		return A[top+1];
	}
}

int main(){
	char c;

	while(scanf("%c",&c)!=EOF){
		if(isdigit(c))push(c-'0');
		else{
			if(c=='+'){
				push(pop()+pop());
			}else if(c=='-'){
				int a = pop();
				push(pop()-a);
			}else if(c=='*'){
				push(pop()*pop());
			}
		}
	}

	printf("%d\n",pop());

}