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