#include <bits/stdc++.h>
int main() {
  int length, i;
  char a[110];
  gets(a);
  length = strlen(a);
  for (i = 0; i < length; i++) {
    if (a[i] == 'H' || a[i] == 'Q' || a[i] == '9') {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}
