#include <bits/stdc++.h>
int main() {
  int i = 0;
  char s[7];
  char c;
  long a[100], temp;
  while (scanf("%s ", s) > 0) {
    c = s[0];
    if (c < '0' || c > '9') {
      switch (c) {
        case '+':
          temp = a[i - 2] + a[i - 1];
          break;
        case '-':
          temp = a[i - 2] - a[i - 1];
          break;
        case '*':
          temp = a[i - 2] * a[i - 1];
          break;
        default:
          break;
      }
      a[i - 2] = temp;
      i = i - 1;
    } else {
      a[i] = atol(s);
      i++;
    }
  }
  printf("%ld\n", a[0]);
  return 0;
}
