#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'Q' or s[i] == 'H' or s[i] == '9') {
      ans++;
    }
  }
  if (ans == 0) {
    cout << "NO";
  } else {
    cout << "YES";
  }
  return 0;
}
