#include <bits/stdc++.h>
int main() {
  char s[100];
  scanf("%s", &s);
  if (strstr(s, "H") != NULL || strstr(s, "Q") != NULL ||
      strstr(s, "9") != NULL) {
    printf("YES");
  } else if (strstr(s, "+") != NULL) {
    printf("NO");
  } else {
    printf("NO");
  }
  return 0;
}
