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