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

int main(void){

  int s[100],i;
  char a[100];
  i=0;
  while(scanf("%s",a) != EOF){
    if(a[0] == '+'){
      s[i - 2] = s[i - 2] + s[i - 1];
      i--;
    }
    
    else if(a[0] == '-'){
      s[i - 2] = s[i - 2] - s[i - 1];
      i--;
    }

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