#include <stdio.h>
#include <stdlib.h>

#define N 200
#define C 10000

int main(){

  int i;
  int count = 0, n = 0;
  char in[N][C];
  int ans[N];
  int out = 0;

  i = 0;
  while(scanf("%s", in[i]) != EOF){

    count++;
    i++;
  }

  for(i = 0; i < count; i++){
    if(in[i][0] == '+'){
      
      ans[n] = atoi(in[i - 2]) + atoi(in[i - 1]);
      n++;
      
    }

    else if(in[i][0] == '-'){
      
      ans[n] = atoi(in[i - 2]) - atoi(in[i - 1]);
      n++;
      
    }
    
    else if(in[i][0] == '*'){
      
      ans[n - 2] = ans[n - 1] * ans[n - 2];
      n--;
    }
    
  }
  
  printf("%d\n", ans[0]);
  
  return 0;
}