#include <bits/stdc++.h>
using namespace std;
int main() {
  int z = 0;
  char bou[1000];
  cin.get(bou, 1000);
  for (int i = 0; (33 <= (int)bou[i]) && ((int)bou[i] <= 126); i++) {
    z++;
  }
  for (int j = 0; j < z; j++) {
    if ((bou[j] == 'H') || (bou[j] == 'Q') || (bou[j] == '9')) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
