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