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

int a[1000], top;

void push(int n) {
  a[top++] = n;
}


int pop() {
  return a[--top];
}


int main() {
  char ch[100];
  int n1, n2;
  top = 0;

  while (scanf("%s", ch) != EOF) {
    if (ch[0] == '+') {
      n1 = pop();
      n2 = pop();
      push(n1 + n2);
    } else if (ch[0] == '-') {
      n1 = pop();
      n2 = pop();
      push(n2 - n1);
    } else if (ch[0] == '*') {
      n1 = pop();
      n2 = pop();
      push(n1 * n2);
    } else {
      push(atoi(ch));
    }
  }

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

  return 0;
}

