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