#include <stdio.h>

#define TRUE 1
#define FALSE -1

void push(int *,int);
int pop(int *);
int isEmpty(int *);

int s_top=0;

int main(){
  char word;
  int stack[100];
  int number=0;
  int number_1=0;
  int number_2=0;
  while((scanf("%s",&word))!=EOF)
    {
      if('0'<=word && word <= '9'){
	number=word-'0';
	push(stack,number);
      }
      else {
	switch(word){
	case '+':
	  number_1=pop(stack);
	  number_2=pop(stack);
	  push(stack,number_1+number_2);
	  break;
	  
	case '-':
	  number_1=pop(stack);
	  number_2=pop(stack);
	  push(stack,number_2-number_1);
	  break;
	  
	case'*':
	  number_1=pop(stack);
	  number_2=pop(stack);
	  push(stack,number_1*number_2);
	  break;
	}
      }
    }
  printf("%d",pop(stack));
  printf("\n");
  return 0;
}

void push(int *S, int x){
  s_top=s_top+1;
  S[s_top]=x;
}

int pop(int *S){
  if(isEmpty(S)==1){
    printf("error\n");
    return 0;
  }
  else s_top=s_top-1;
  return S[s_top+1];
}

int isEmpty(int *S){
  if(s_top==0)return TRUE;
  else return FALSE;
}

