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