#include <stdio.h>
#include <stdlib.h>
#define Max 100   //?????§???????????????
#define SUCCESS 1 //??????
#define FAILURE 0 //??±???
int top = 0;

int initialize(int); 
//top???0??¨??????????????????????????????
int isEmpty(int);     
//top???0???????????????????????????????????????????????????????????????
int isFull(int);      
//??????????????????????????????????????????
int push(int *,int);
//top???1????¢????????????????x?????????
int pop(int *);         
//top?????????????´?(????????????????????????????´?)???????????????top??????????????????????????????????´??????????


int initialize(int S){
  S = 0;
}


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


int isFull(int top){
  if(top >= Max - 1) return FAILURE;
  else return SUCCESS;
}


int push(int *S,int x){

  if(isFull(top) == 0){
   printf("Over Flow !!\n");
   exit(8);
 }

 top++;
 S[top] = x;
 return S[top];
}

int pop(int *S){

  if(isEmpty(top) == 0){
    printf("Uneder Flow !!\n");
    exit(8);
  }

  top--;
  return S[top+1];
}


int main(void){

  char X;
  int Stuck[Max],i=1,j;

  initialize(Stuck[0]);

  while(1){

    if(scanf("%c",&X) == EOF) break;
    else if(X == '+'){
      Stuck[i-2] = pop(Stuck) + pop(Stuck);
    }
    else if(X == '-'){
      Stuck[i-2] = pop(Stuck) - pop(Stuck);
    }
    else if(X == '*'){
      Stuck[i-2] = pop(Stuck) * pop(Stuck);
    }
    Stuck[i] = push(Stuck,X);

    printf("i : %d\n",i);
    for(j = 0; j < i; j++) printf("S%d : %d  ",j,Stuck[j]);
    printf("\n");

    i++;

  }

  //printf("%d\n",Stuck[0]);
  return 0;
}