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