#include <stdio.h>
int st[100],head=0;
int main(){
  int b,num=0;
  char a,c;
  
  while( (scanf("%c",&a))!=EOF){ 
   
      if(a<='9'&&a>='0'){num=a-'0'+num*10;}      
      else if(num!=0){	
st[head]=num;
	head++;
	num=0;
      }
      else {num=0;
	if(a=='+'){
	  st[head-2]+=st[head-1];
	  head--;
	}
	else if(a=='*'){
	  st[head-2]*=st[head-1];
	  head--;
	}

	else if(a=='-'){
	  st[head-2]-=st[head-1];
	  head--;
	}
      }  
  }
  printf("%d\n",st[head-1]);  

  return 0;
}