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