#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string second;
  cin >> second;
  int i = 0;
  int cnt = 0;
  while (second[i] != '\0') {
    if ((second[i] == 'H' || second[i] == 'Q' || second[i] == '9')) {
      cnt++;
    }
    i++;
  }
  if (cnt > 0) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
