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