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

int main(){
  char c;
  int i;
  int cnt=0, cnu=0;
  int op[2];
  int cul[3];

  while(scanf("%c", &c)!=EOF){
    if(c=='\n'){
      break;
    }
    
    if(c>='0' && c<='9'){
      op[cnu]=c-'0';
      if(++cnu>2) exit(1);
    }

    else if(c=='+' && cnu>1){
      cul[cnt]=op[cnu-2]+op[cnu-1];
      if(++cnt>3) exit(1);
      cnu=0;
    }
    else if(c=='-' && cnu>1){
      cul[cnt]=op[cnu-2]-op[cnu-1];
      if(++cnt>3) exit(1);
      cnu=0;
    }
    else if(c=='*' && cnt>=2){
      cul[cnt-2]=cul[cnt-2]*cul[cnt-1];
      cnt=1;
    }
    else;
  }

  printf("%d\n", cul[0]);
}