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

#define TRUE 1
#define FALSE 0
#define MAX 101

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

int top=0;
char s[100];
int c[101];

int main(){
  int x,y,z;

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      x = pop() + pop();
      push(x);
    }
    else if(s[0] == '-'){
      y = pop();
      z = pop();
      x = z - y;
      push(x);
    }
    else if(s[0] == '*'){
      x = pop() * pop();
      push(x);
    }
    else{
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",c[top]);

  return 0;
}

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

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

void push(int x){
  int a;
  a = isFull();

  if(a == 1){
    printf("error\n");
  }
  else{
    top++;
    c[top] = x;
  }
}

int pop(){
  int b,re;
  b = isEmpty();

  if(b == 1){
    printf("error\n");
  }
  else{
    top--;
    re = c[top+1];
    return re;
  }
}