#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long int sz = s.size(), a = 0;
  for (long long int i = 0; i < sz; i++) {
    if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9') {
      cout << "YES";
      a = 10;
      break;
    }
  }
  if (a != 10) cout << "NO";
  return 0;
}
