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