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