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