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