#include <bits/stdc++.h>
using namespace std;
int main() {
  string input;
  int tr = 0;
  cin >> input;
  int i = 0;
  while ((tr != 1) && (i < input.length())) {
    if ((input.at(i) == 72) || (input.at(i) == 81) || (input.at(i) == 57)) {
      tr = 1;
    }
    ++i;
  }
  if (tr) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
