#include <bits/stdc++.h>
int main() {
  char string[101];
  int i = 0;
  while (scanf("%c", &string[i]) && string[i++] != '\n')
    if (string[i - 1] == 'H' || string[i - 1] == 'Q' || string[i - 1] == '9') {
      printf("YES");
      exit(0);
    }
  printf("NO");
}
