#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  for (int i = 0; i < str.size(); i++) {
    char t = str.at(i);
    if (t == 'H' || t == 'Q' || t == '9') {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
