#include<stdio.h>
int main(){
  char s[100];
  int j=0,stack[200],top=0,status;
  
  while(1){
    status=scanf("%s",s);
    if(status==EOF) break;
    if(s[0]=='+'){
      stack[top-2]=stack[top-2]+stack[top-1];
      top--;
    }
      
    else if(s[0]=='-'){
      stack[top-2]=stack[top-2]-stack[top-1];
    top--;
    }
    else if(s[0]=='*'){
      stack[top-2]=stack[top-2]*stack[top-1];
      top--;
    }
    else {
      stack[top]=atoi(&s[0]);
      top++;
    }
    
    
  }
  printf("%d\n",stack[0]);
  return 0;
}
      

