#include <bits/stdc++.h>
const int N = 100007;
using namespace std;
char s[N];
int main() {
  scanf("%s", s);
  int i, len;
  len = strlen(s);
  int tmp = 0;
  for (i = 0; i < len; i++) {
    if (s[i] + tmp == 'H' || s[i] + tmp == 'Q' || s[i] + tmp == '9') {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}
