#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, t, n, m, len = 0, sum = 0, p, c, temp, ans = 0, s;
  string a;
  cin >> a;
  l = a.length();
  for (i = 0; i < l; i++) {
    if (a[i] == 'H' || a[i] == 'Q' || a[i] == '9') ans++;
  }
  if (ans != 0)
    cout << "YES";
  else
    cout << "NO";
}
