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