#include <bits/stdc++.h>
using namespace std;
string str;
int n, k, AnswerN;
int check;
int main(int argc, char** argv) {
  int test_case, T;
  T = 1;
  for (test_case = 1; test_case <= T; ++test_case) {
    check = 0;
    cin >> str;
    for (int i = 0; i < str.length(); i++) {
      if ((str[i] == 'H') || (str[i] == 'Q') || (str[i] == '9')) {
        check = 1;
      }
    }
    if (check == 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    AnswerN = 0;
  }
}
