#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  map<char, int> make_pair;
  for (char ch : str) {
    make_pair[ch]++;
  }
  if (make_pair.find('H') != make_pair.end() ||
      make_pair.find('9') != make_pair.end() |
          make_pair.find('Q') != make_pair.end())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
