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

#define N 100

static int num[N];
static int ind = 0;

void push(int value) {
    ind++;
  num[ind] = value;
}

int pop() {
  int tmp = num[ind];
  ind--;
  return tmp;
}

int main() {
    int i = 0, n, tmp;
    int j;
    int result = 0;
    char value;
    char calc[N];
    while(scanf("%s", calc) != EOF) {
      if(calc[0] == '+') {
        result = pop() + pop();
        push(result);
      } else if(calc[0] == '-') {
        tmp = pop();
        result = pop() - tmp;
        push(result);
      } else if(calc[0] == '*') {
        result = pop() * pop();
        push(result);
      } else {
        n=0;
          for(j = 0; j < calc[j]!='\0'; j++) {
            n = n * 10 + (calc[j] - '0');
          }
          push(n);
      }
    }
      printf("%d\n", pop());
      return 0;
}