#include <stdio.h>
#include <stdlib.h>
int main()
{
 
  int stack[100];
  char str[100];
  int top=0,i;
  int ch;
  for (i=0;i<100;i++){
    stack[i]=0;
  }
  while (scanf("%s",str)!=EOF){
    if (str[0]=='+'){
      stack[top-2]=stack[top-2]+stack[top-1];
      top=top-1;
    }else if(str[0]=='*'){
      stack[top-2]=stack[top-2]*stack[top-1];
      top=top-1;
    }else if(str[0]=='-'){
      stack[top-2]=stack[top-2]-stack[top-1];
      top=top-1;
    }else{
      stack[top]=atoi(str);
      top++;
    }
  }
  printf("%d\n",stack[top-1]);
  return 0;
}

