#include<stdio.h>

int main(){
  int x,fi[100],top=0;
  char s[7];
  int c;


  while( scanf("%s", s) != EOF ){
    if(s[0]=='\n')break;
    //if((c=getchar())=='\n')break;
    if ( s[0] == '+' ){
      fi[top-1]=fi[top]+fi[top-1];
      top--;
    }
    else if ( s[0] == '-' ){
      fi[top-1]=fi[top-1]-fi[top];
      top--;
    }
    else if ( s[0] == '*' ){
      fi[top-1]=fi[top]*fi[top-1];
      top--;
    }
    else {
      x = atoi(s);
      fi[top+1]=x;
      top++;
    }
    //printf("ssss\n");
  }

  printf("%d\n",fi[top]);

  return 0;
}

