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

main(){
  int stack[200];
  int i,j,temp1,temp2,s;
  char a[7];
  
  for(i=0;i<200;){
    scanf("%c",&a[0]);
    if(a[0]>='0'){          /* Input is operand case. */
      for(j=1;j<7;j++){
	scanf("%c",&a[j]);
	if(a[j]==' ')break;
      }
      a[j]='\0';
      stack[i]=atoi(a);
      i++;
    }
    if(a[0]=='*'){          /* Input is operator case. */
      temp1=stack[i-2];
      temp2=stack[i-1];
      i--;
      stack[i-1]=temp1*temp2;
    }
    if(a[0]=='+'){
      temp1=stack[i-2];
      temp2=stack[i-1];
      i--;
      stack[i-1]=temp1+temp2;
    }
    if(a[0]=='-'){
      temp1=stack[i-2];
      temp2=stack[i-1];
      i--;
      stack[i-1]=temp1-temp2;
    }
    if(a[0]=='\n')break;
  }
  
  printf("%d\n",stack[0]);
  
  return 0;
}