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