#include <stdio.h>

#define MAX_OPERANDS 128

int opeStack[MAX_OPERANDS];
int opeSp = 0;

int main(int argc, char* argv[]) {
  int tmp = 0;
  for (;;) {
    int c = getchar();
    if (c == EOF) break;
    if (c == ' ') {
      opeStack[opeSp++] = tmp;
      tmp = 0;
      continue;
    }
    if ('0' <= c && c <= '9') {
      tmp *= 10;
      tmp += c - '0';
      continue;
    }
    if (c == '+') {
      opeStack[opeSp - 2] = opeStack[opeSp - 2] + opeStack[opeSp - 1];
    } else if (c == '-') {
      opeStack[opeSp - 2] = opeStack[opeSp - 2] - opeStack[opeSp - 1];
    } else if (c == '*') {
      opeStack[opeSp - 2] = opeStack[opeSp - 2] * opeStack[opeSp - 1];
    }
    opeSp--;
    getchar();
  }
  printf("%d\n", opeStack[0]);
  return 0;
}