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

int main(void){
  int i=0;
  int a[100];
  char b[100];

  while(scanf("%s",b) != EOF){
    if(b[0] == '+'){
      a[i-2] = a[i-2] + a[i-1];
      i--;
    }

    else if(b[0] == '-'){
      a[i-2] = a[i-2] - a[i-1];
      i--;
    }

    else if(b[0] == '*'){
      a[i-2] = a[i-2] * a[i-1];
      i--;
    }

    else{
      a[i] = atoi(b);
      i++;
    }
  }
  printf("%d",a[0]);
  printf("\n");
  return 0;
}

