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