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

int se,deta[1000];

void pu1(int a){
  deta[++se] = a;
}


int cal(){
  se--;
  return deta[se+1];
}

int main(){
  int x,y;
  se = 0;
  char r[100];

  while( scanf("%s",r) != EOF){
    if(r[0] == '+'){
      x = cal();
      y= cal();
      pu1(x+y);
    }
    else if(r[0] == '-'){
      y = cal();
      x = cal();
      pu1(x-y);
    }

    else if(r[0] == '*'){
      x = cal();
      y = cal();
      pu1(x*y);
    }

    else{
      pu1(atoi(r));
    }
  }

  printf("%d\n",cal());

  return 0;
}

