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

#define N_MAX 100

int S[N_MAX], top;

void initialize(void) {
  top = 0;
}

int isEmpty(void) {
  if (top == 0) {
    return 1;
  } else {
    return 0;
  }
}

int isFull(void) {
  if (top == N_MAX - 1) {
    return 1;
  } else {
    return 0;
  }
}

void push(int x) {
  if (isFull()) {
    printf("push error!\n");
  } else {
    //printf("push %d\n", x);
    S[top] = x;
    top++;
  }
}

int pop(void) {
  if (isEmpty()) {
    printf("pop error!\n");
    return 0;
  } else {
    top--;
    int tmp = S[top];

    //printf("pop %d\n", tmp);
    return tmp;
  }
}

int main(int argc, char const *argv[]) {
  char t[100];
  int a, b;

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

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

  return 0;
}