#include <bits/stdc++.h>
int main() {
  char A[1000];
  std::cin >> A;
  int n = strlen(A);
  for (int i = 0; i < n; i++) {
    if (A[i] == 'H' || A[i] == 'Q' || A[i] == '9') {
      std::cout << "YES" << '\n';
      return 0;
    }
  }
  std::cout << "NO" << '\n';
  return 0;
}
