#include <stdio.h>

int main()
{
  int x, y, z;
  char line[1024];
  fgets(line, 1024, stdin);
  int a[100];
  int sp = 0;
  for (char *p=line; *p!='\n';p++) {
    if (*p=='+') {
      x = a[--sp];
      y = a[--sp];
      a[sp++] = x + y;
    } else if (*p=='-') {
      x = a[--sp];
      y = a[--sp];
      a[sp++] = -x + y;
    } else if (*p=='*') {
      x = a[--sp];
      y = a[--sp];
      a[sp++] = x * y;
    } else if (*p>='0'){
      for (z = 0; *p>='0'; p++) z = z * 10 + *p - '0';
      a[sp++] = z;
    }
  }
  printf("%d\n", a[--sp]);

  return 0;
}

