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