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