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

int stack[101], n;

int isFull() {
  return n == 100;
}

int isEmpty() {
  return n == 0;
}

void push(int a) {
  if(!isFull())
    stack[++n] = a;
}

int pop() {
  if(!isEmpty())
    return stack[n--];

  return 0;
}

int main(void) {
  int a, b;
  char str[100];
  n = 0;

  while(scanf("%s", str) != EOF) {
    switch(str[0]) {
      case '+':
        a = pop();
        b = pop();
        push(b + a);
        break;
      case '-':
        a = pop();
        b = pop();
        push(b - a);
        break;
      case '*':
        a = pop();
        b = pop();
        push(b * a);
        break;
      default:
        push(atoi(str));
        break;
    }
  }

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

  return 0;
}

