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