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