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

int main(){

  char c[10];
  int st[100];
  int top=0;

  while(scanf("%s",c)!=EOF){
  
    if(strcmp(c,"+")==0){
      st[top-2]=st[top-2]+st[top-1];
      top--;
      printf("+ ");

    }else if(strcmp(c,"-")==0){
      st[top-2]=st[top-2]-st[top-1];
      top--;
      printf("- ");

    }else if(strcmp(c,"*")==0){
      st[top-2]=st[top-2]*st[top-1];
      top--;;
      printf("* ");

    }else{
      st[top]=atoi(c);
      printf("%d ",st[top]);
      top++;

    }

  }

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


  return 0;
}