#include <stdio.h>
#include <string.h>

int main() {
  int x, top = 0, stack[100];
  char s[100];

  while(scanf("%s", s) != EOF) {
    if(s[0] == '+') {
      stack[top-2] += stack[top-1];
      top--;
    } else if(s[0] == '-') {
      stack[top-2] -= stack[top-1];
      top--;
    } else if(s[0] == '*') {
      stack[top-2] *= stack[top-1];
      top--;
    } else {
      x = atoi(s);
      stack[top++] = x;
    }
  }
  printf("%d\n", stack[0]);
  return 0;
}

