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