#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string s;
  cin >> s;
  bool flag = false;
  for (long long i = 0; i < s.length(); i++) {
    if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9') {
      flag = true;
      break;
    }
  }
  cout << ((flag) ? "YES" : "NO");
  return 0;
}
