void push(int);
int  pop(void);

main(){
  int x, a, b;
  char s[1000000];
  while(scanf("%s", s) != EOF){
    switch(s[0]){
    case '+':
      a = pop();
      b = pop();
      top++;
      operands[top] = a + b;
      break;
      
    case '-':
      a = pop();
      b = pop();
      top++;
      operands[top] = b - a;
      break;
      
    case '*':
      a = pop();
      b = pop();
      top++;
      operands[top] = a * b;
      break;
      
    default :
      x = atoi(s);
      push(x);
      break;
    }
  }
  printf("%d\n", operands[1]);
  return 0;
}

void push(int x){
  top++;
  operands[top] = x;
}

int pop(){
  top--;
  return operands[top+1];
}