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