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

static int stack[100];
static int top = 0;

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

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

int main(void) {
  int a, b;
  char input[100];
  
  while ( scanf("%s", input) != EOF ) {
    switch (input[0]) {
    case '+':
      a = pop();
      b = pop();
      push(a+b);
      break;
    case '-':
      a = pop();
      b = pop();
      push(a-b);
      break;
    case '*':
      a = pop();
      b = pop();
      push(a*b);
      break;
    case '\n':
      break;
    default:
      push(atoi(input));
    }
  }
  printf("%d\n", pop());
  //printf("stack:\n%d\n%d\n%d\n", stack[3], stack[2], stack[1]);

  return 0;
}
