#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j, t, k, c, l, sum1, sum;
  string p;
  cin >> p;
  {
    c = 0;
    l = p.size();
    for (i = 0; i < l; i++) {
      if (p[i] == 'H' || p[i] == 'Q' || p[i] == '9') {
        c++;
        cout << "YES"
             << "\n";
        break;
      }
    }
    if (c == 0)
      cout << "NO"
           << "\n";
  }
  return 0;
}
