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