#include <stdio.h>


main()
{

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

}