#include<stdio.h>

int main(){
  int key[50];
  char p;
  int top=0;

  while(1){
    if(scanf(" %c",&p)==EOF)break;
    if(p=='+'||p=='-'||p=='*')top--;
    else key[top]=p-'0';

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

    if(p=='+'){
      key[top-1]=(key[top-1]) + (key[top]);
      printf("%d\n",key[top-1]);
    }
    else if(p=='-'){
      key[top-1]=(key[top-1])-(key[top]);
    }
    else if(p=='*'){
      key[top-1]=(key[top-1])*(key[top]);
    }
    else top++;
  }

  printf("%d\n",(key[top-1]));

  return 0;
}
      
 
    

