#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k = 0;
  for (auto c : s) {
    if (c == 'H' || c == 'Q' || c == '9') {
      k++;
      break;
    }
  }
  if (k > 0)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
