#include<stdio.h>
#include<stdlib.h>
#define MAX 1000

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

int stack[MAX];
int top;

int main(){
  int i=1;
  int a,b,x;
  char s[100];

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

void initialize(){
  top = 0;
}

int isEmpty(){
  if(top==0) return 0;
  else return 1;
}

int isFull(){
  if(top >= MAX - 1) return 0;
  else return 1;
}

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

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


