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

int main(void)
{
  int sta  [100] = {};
  char input;
  int i=1;

  while((scanf("%s",&input)) != EOF){
    if(input >= '0' && input <= '9'){
      sta[i] = atoi(&input);
      i++;
    }
    else{
      if(input == '+'){
	sta[i-2] = (sta[i-2]) + (sta[i-1]);
      }
      else if(input == '-'){
	sta[i-2] = (sta[i-2]) - (sta[i-1]);
      }
      else if(input == '*'){
	sta[i-2] = (sta[i-2]) * (sta[i-1]);
      }
      else if(input == '\0'){
	break;
      }
      else{
	i++;
      }
      i--;
    }
  }
  
  printf("%d\n",sta[1]);
  
  return(0);
}