#include <bits/stdc++.h>
using namespace std;
int main() {
  string inst;
  int i = 0, len;
  cin >> inst;
  len = inst.length();
  while (i != len) {
    if (inst[i] == 'H' || inst[i] == 'Q' || inst[i] == '9') {
      cout << "YES";
      break;
    }
    i = i + 1;
  }
  if (i == len) {
    cout << "NO";
  }
  return 0;
}
