#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[100];
  bool flag;
  int i, k;
  while (cin >> s) {
    flag = true;
    k = strlen(s);
    for (i = 0; i < k; i++) {
      if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9') {
        cout << "YES" << endl;
        flag = false;
        break;
      }
    }
    if (flag) cout << "NO" << endl;
  }
  return 0;
}
