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