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

#define MAX 100

int main()
{
  int i, top, num1, num2, array[MAX];
  char word[1];

  top = 0;

  while(1){
    scanf("%c", &word[0]);

    if( word[0] == ' ')continue;

    if( word[0] == '\n'){
      printf("%d\n", array[1]);
      break;
    }

    if( word[0] >= '0' && word[0] <= '9' ){
      if( top >= MAX - 1 ){
	printf("overflow error\n");
	break;
      }
      top++;
      array[top] = atoi(word);
    }

    if( word[0] == '+' || word[0] == '-' || word[0] == '*' ){
     if( top == 0 ){
	printf("underflow error\n");
	break;
      }
     num1 = array[top-1];
     num2 = array[top];
     top--;
     
     if( word[0] == '+' ){
       array[top] = num1 + num2;
     }
     else if( word[0] == '-' ){
       array[top] = num1 - num2;
     }
     else if( word[0] == '*' ){
       array[top] = num1 * num2;
     }
     num1 = 0;
     num2 = 0;
    }
  }
  
  return 0;
}