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