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

int main(){
  int S[100], num;
  char s[200];

  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      S[num-1] = S[num-1] + S[num];
      num--;
    }
    else if(s[0] == '-'){
      S[num-1] = S[num-1] - S[num];
      num--;
    }
    else if(s[0] == '*'){
      S[num-1] = S[num-1] * S[num];
      num--;
    }
    else{
      num++;
      S[num] = atoi(s);
    }
  }
  printf("%d\n", S[num]);
  return 0;
}

