#include <bits/stdc++.h>
using namespace std;
int main() {
  char a;
  bool t = true;
  while (cin >> a) {
    if (a == 'Q' || a == 'H' || a == '9') {
      t = false;
    }
  }
  if (!t)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
