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