#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[110];
  cin >> str;
  int i = 0;
  bool isPossible = false;
  for (i = 0; i < strlen(str); i++) {
    if (str[i] >= '!' && str[i] <= '~')
      if (str[i] == 'H' || str[i] == 'Q' || str[i] == '9') {
        isPossible = true;
      }
  }
  if (isPossible == true)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
