#include <bits/stdc++.h>
using namespace std;
char s[110];
bool resp = false;
int main() {
  scanf("%s", s);
  int size = strlen(s);
  for (int i = 0; i < size; ++i) {
    if (s[i] == 'H' or s[i] == 'Q' or s[i] == '9') {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
}
