#include <stdio.h>

main()
{

  int stack[100];
  int top=0;
  char ch;
  while ((ch=getchar())!='\n'){
    if (ch=='+'){
      stack[top-2]=stack[top-2]+stack[top-1];
      top=top-2;
    }else if(ch=='*'){
      stack[top-2]=stack[top-2]*stack[top-1];
      top=top-2;
    }else if(ch=='-'){
      stack[top-2]=stack[top-2]-stack[top-1];
      top=top-2;
    }else if (ch!=' '){
      stack[top]=ch-'0';
      top++;
    }
  }
  printf("%d\n",stack[top]);

}