#include <bits/stdc++.h>
using namespace std;
int main() {
  string line;
  bool check = true;
  cin >> line;
  for (int i = 0; i < line.length(); i++) {
    if ((line[i] == 'H') || (line[i] == 'Q') || (line[i] == '9')) {
      cout << "YES" << endl;
      check = false;
      break;
    }
  }
  if (check) {
    cout << "NO" << endl;
  }
  return 0;
}
