#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  auto it = s.find("H");
  auto it1 = s.find("Q");
  auto it2 = s.find("9");
  if (it == string::npos && it1 == string::npos && it2 == string::npos) {
    cout << "NO";
  } else
    cout << "YES";
}
