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