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