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

int str[100];
int top;

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

int main() {
  char s[100];
  int a,b;

  top = 0;

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


  printf("%d\n",pop());
return 0;
}


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

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

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

