#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string str;
  cin >> str;
  bool flag = false;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'H' || str[i] == 'Q' || str[i] == '9') {
      flag = true;
      break;
    }
  }
  if (flag)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
