#include <stdio.h>
#include <stdlib.h>
#define MAX 100

typedef struct __stack_ {
  int stack[MAX];
  int top;
} __stack_t;
__stack_t S;

void initialize() {
  S.top = 0;
}

int isEmpty() {
  return 0 == S.top;
}


int isFull() {
  return S.top >= (MAX - 1);
}

void push(const int x) {
  if (isFull()) {
    printf("Error: Overflow\n");
    return;
  }
  S.stack[++S.top] = x;
}

int pop() {
  if (isEmpty()) {
    printf("Error: Underflow\n");
    return 0;
  }
  return S.stack[S.top--];
}

void showStack() {
  int i;
  for (i = 1; i < S.top; i++) {
    printf("%d ", S.stack[i]);
  }
  printf("%d\n", S.stack[S.top]);
}

int main() {
  char c;
  while (scanf("%c", &c)) {
    int a, b;
    switch (c) {
      case '+':
        a = pop();
        b = pop();
        push(a + b);
        break;
      case '-':
        a = pop();
        b = pop();
        push(b - a);
        break;
      case '*':
        a = pop();
        b = pop();
        push(a * b);
        break;
      case '\n':
        printf("%d\n", pop());
        return 0;
      case ' ':
        break;
      default:
        push(atoi(&c));
        break;
    }
//    showStack();
  }
  return 0;
}