#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.find('H') != -1) {
    cout << "YES";
    return 0;
  } else if (s.find('Q') != -1) {
    cout << "YES";
    return 0;
  } else if (s.find('9') != -1) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
}
