#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] >= 33 && s[i] <= 126 &&
        (s[i] == 'H' || s[i] == 'Q' || s[i] == '9')) {
      count = count + 1;
    }
  }
  if (count > 0) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
