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