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

int isEmpty(char);
int isFull();
void push(int);
int pop();

int top=0,B[150];
char A[10];

int main(){
  int i,a,b,temp;

  while(scanf("%s",A) != EOF){
    if(A[0] == '+'){
      a = pop();
      b = pop();
      temp = a + b;
      push(temp);
    }else if(A[0] == '-'){
      a = pop();
      b = pop();
      temp = b - a;
      push(temp);
    }else if(A[0] == '*'){
      a = pop();
      b = pop();
      temp = a * b;
      push(temp);
    }else{
      temp = atoi(A);
      push(temp);
    }
  }
  
  printf("%d\n",pop());
  return 0;
}

void push(int x){
  if(top > 149){
    printf("error\n");
    exit(1);
  }
  top++;
  B[top] = x;
}

int pop(void){
  if(top == 0){
    printf("error\n");
    exit(1);
  }
  top--;
  return B[top+1];
}
  

