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

int stack[100], top;

void push(int x) {
  stack[++top] = x;
}

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

int main(void) {
  int a, b;
  char op[1];
  top = 0;

  while(scanf("%s", op) != EOF) {
    if(op[0] == '+') {
      b = pop();
      a = pop();
      push(a + b);
    }
    else if(op[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(op[0] == '*') {
      b = pop();
      a = pop();
      push(a * b);
    }
    else {
      push(atoi(op));
    }
  }
  printf("%d\n", pop());
  return 0;
}