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