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