#include <bits/stdc++.h>
int main() {
  char a[1000];
  int n;
  scanf("%s", a);
  n = strlen(a);
  for (int i = 0; i < n; i++) {
    if (a[i] == 'H' || a[i] == 'Q' || a[i] == '9') {
      printf("YES");
      return 0;
    }
  }
  printf("NO");
  return 0;
}
