#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  string line;
  getline(cin, line);
  for (const char& c : line)
    if (c == 'H' || c == 'Q' || c == '9') {
      cout << "YES";
      return 0;
    }
  cout << "NO";
}
