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

#define N 100

int main(){
  char str[10] = {""};
  int stac[N];
  int top = 0, num1, num2, i, j;
  
  i = 0;
  while((str[i] = getchar())!= EOF){
    if(str[i] != ' '){
      i++;
    }
    else{
      i = 0;
      num1 = atoi(str);
      if(num1 != 0){
	top++;
	stac[top] = num1;
      }
      else{
	
	if(str[0] == '+'){
	  //printf("calc +\n");
	  stac[top-1] = stac[top-1] + stac[top];
	  top--;
	}
	if(str[0] == '-'){
	  //printf("calc -\n");
	  stac[top-1] = stac[top-1] - stac[top];
	  top--;
	}
	if(str[0] == '*'){
	  //printf("calc *\n");
	  stac[top-1] = stac[top-1] * stac[top];
	  top--;
	}
      }
      
      strcpy(str ,"");
      /*
      for(j = 1; j < top+1; j++){
	printf("%d ", stac[j]);
	}
      */
    }
  }
  
  if(str[0] == '+'){
    //printf("calc +\n");
    stac[top-1] = stac[top-1] + stac[top];
    top--;
  }
  if(str[0] == '-'){
    //printf("calc -\n");
    stac[top-1] = stac[top-1] - stac[top];
    top--;
  }
  if(str[0] == '*'){
    //printf("calc *\n");
    stac[top-1] = stac[top-1] * stac[top];
    top--;
  }

    printf("%d\n", stac[top]);
    
  return 0;
}

