#include <bits/stdc++.h>
using namespace std;
int main() {
  string p;
  cin >> p;
  int k = 0;
  for (int i = 0; i < p.size(); i++) {
    if (p[i] == 'H' || p[i] == 'Q' || p[i] == '9') k++;
  }
  if (k == 0)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
