#include <bits/stdc++.h>
using namespace std;
char s[100005];
int n, i, m, j, a, q, top;
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (i = 0; i < n; i++)
    if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9') q += 1;
  if (q > 0) printf("YES");
  if (q == 0) printf("NO");
}
