#include <bits/stdc++.h>
using namespace std;
int main() {
  int f = 0;
  string a;
  cin >> a;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == 'Q' or a[i] == 'H' or a[i] == '9') {
      f++;
    }
  }
  if (f > 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
