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