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