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