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