#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(){
	int c;
	int tmp;
	while(scanf("%d",&c)!=EOF){
		if(c=='+'){
			push(pop()+pop());
		}else if(c=='-'){
			tmp = pop();
			push(pop() - tmp);
		}else if(c=='*'){
			push(pop()*pop());
		}
		else{
			push(c);
		}
	}


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

}