#include <stdio.h>
#include <stdlib.h>
#define N 100  

int main(void){
  int i;
  int num[N];
  char enzan[N];
  
  int head=0;
  
  for(i = 0; i < N; i++){
    enzan[i]=0;
  }
  
  while (scanf("%s",enzan) != EOF){
    if ( enzan[0] == '+'){
      num[head-2] = num[head-2] + num[head-1];
      head--;
    }   
    else if(enzan[0] == '*'){
      num[head-2] = num[head-2] * num[head-1];
      head--;
    }
    else if(enzan[0] == '-'){
      num[head-2] = num[head-2] - num[head-1];
      head--;
    }
    else {
      num[head] = atoi(enzan);
      head++;
    }
  }
  printf("%d\n",num[head-1]);
  return 0;
}