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

int s[100];
int top = 0;

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

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

int main(void) {
  int a, b;
  char v[10];

  while(scanf("%s ", v) != EOF) {
    if (v[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    }
    else if (v[0] == '-') {
      a = pop();
      b = pop();
      push(b - a);
    }
    else if (v[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    }
    else {
      push(atoi(v));
    }
  }

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

