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