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


int isEmpty(int);


int main(){

  int i=0,j,top;
  int str[200];
  char c[100];

  
  for(i=1;i<200;i++){
    if(scanf("%s",&c)==EOF)break;
    
    else if(isEmpty(i)==1){
	if(!strcmp(c,"+")){
	  str[i-2] = str[i-1]+str[i-2];
	  i=i-2;
	}
	else if(!strcmp(c,"-")){
	  str[i-2] = str[i-2]-str[i-1];
	  i=i-2;
	}
	else if(!strcmp(c,"*")){
	  str[i-2] = str[i-1]*str[i-2];
	  i=i-2;
	}  
	else str[i] =atoi(c);
    }
    else if(isEmpty(i-2)==0)break;
  }
      
  

  printf("%d\n",str[1]);

  return 0;
}


int isEmpty(int x){

  if(x==0) return 0;
  else return 1;
}