#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
string toBinary(int n) {
  string r;
  while (n != 0) {
    r = (n % 2 == 0 ? "0" : "1") + r;
    n /= 2;
  }
  return r;
}
void swap(int *x, int *y) {
  int temp = *x;
  *x = *y;
  *y = temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  bool flag = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9') {
      flag = true;
      break;
    }
  }
  flag == true ? cout << "YES" : cout << "NO";
  return 0;
}
