#include <stdio.h>
#include <stdlib.h>
#define N_MAX 100

int main(){
  int top = 0, a[N_MAX];
  char s[1000];
  
  while(scanf("%s", &s) != EOF){
    if(s[0] == '+'){
      a[top - 2] = a[top - 1] + a[top - 2];
      top--;
    }
    else if(s[0] == '-'){
      a[top - 2] = a[top - 2] - a[top - 1];
      top--;
    }
    else if(s[0] == '*'){
      a[top - 2] = a[top - 1] * a[top - 2];
      top--;
    }
    else{
      a[top] = atoi(s);
      top++;
    }
  }
  printf("%d\n", a[top - 1]);
  return 0;
}
