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


main(){
  char ST[10];
  int X[100],s,i=0;
  
  while(scanf("%s",ST) != EOF){
    if(ST[0] == '+'){
      X[i-2] = X[i-2] + X[i-1];
      i--;
    }
    else if(ST[0] == '-'){
      X[i-2] = X[i-2] - X[i-1];
      i--;
    }
    else if(ST[0] == '*'){
      X[i-2] = X[i-2] * X[i-1];
      i--;
    }
    else{
      s = atoi(ST);
      X[i] = s;
      i++;
    }
  }
  printf("%d\n",X[0]);
  return 0;
}