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