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

#define MAX 100

void push(int);
int pop(void);
int isEmpty(void);
int isFull(void);

int top = 0;
int stack[MAX];

int main() {
  int n = 0, result = 0;
  int operand[2];
  char input[100];

  while(scanf("%s", input) != EOF) {
    if(input[0] == '+') {
      operand[1] = pop();
      operand[0] = pop();
      push(operand[0] + operand[1]);
    }else if(input[0] == '-') {
      operand[1] = pop();
      operand[0] = pop();
      push(operand[0] - operand[1]);
    }else if(input[0] == '*') {
      operand[1] = pop();
      operand[0] = pop();
      push(operand[0] * operand[1]);
    }else {
      n = atoi(input);
      push(n);
    }
  }

  result = pop();

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

  return 0;
  
}

void push(int x) {
  if(isFull() != 1) {
  stack[top] = x;
  top++;
  }else printf("Stack is full.\n");
}

int pop(void) {
  int r = 0;
  if(isEmpty() != 1) {
    top--;
    r = stack[top];
    return r;
  }else printf("Stack is empty.\n");

  return;
}

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

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