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