#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  char s[110];
  while (scanf("%s", s) != EOF) {
    int len = strlen(s);
    int flag = 0;
    for (i = 0; i < len; i++) {
      if (s[i] == 'Q')
        flag = 1;
      else if (s[i] == 'H')
        flag = 1;
      else if (s[i] == '9')
        flag = 1;
    }
    if (flag == 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
