#include <stdio.h>
#include <ctype.h>

int S[100];
int top;

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

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

int main() {
  char a;
  while ((a = getchar()) != EOF) {
    int tmp;
    if (a == '+') {
      tmp = pop();
      S[top-1] += tmp;
    }
    else if (a == '-') {
      tmp = pop();
      S[top-1] -= tmp;
    }
    else if (a == '*') {
      tmp = pop();
      S[top-1] *= tmp;
    }
    else if (isdigit(a)){
      push(a-'0');
    }
  }
  printf("%d\n", S[top-1]);
  return 0;
}

