#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MAX 200

void push(int);
int pop1(void);

int top = 1;
int s[MAX];

int main(){
  int x,a,b;
  char stack[MAX];

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

  void push(int x)
  {
    if(top >= MAX - 1)
      {
        printf("Overflow!\n");
        exit(1);
      }
    top++;
    s[top] = x;
  }

  int pop1(void)
  {
    if(top == 0)
      {
        printf("Underflow!\n");
        exit(1);
      }
    return s[top--];
  }

