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