#include <bits/stdc++.h>
using namespace std;
int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b) { return a % b ? gcd(b, a % b) : b; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
void quicken() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void file() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int main() {
  quicken();
  string str;
  cin >> str;
  if (str.find('H') != string::npos || str.find('Q') != string::npos ||
      str.find('9') != string::npos)
    cout << "YES";
  else
    cout << "NO";
}
unsigned long long pow(long long base, long long power) {
  if (power == 0) return 1;
  if (power == 1) return base;
  unsigned long long ans = pow(base, power / 2);
  ans *= ans;
  if (power & 1) return ans * base;
  return ans;
}
int sieve(int n) {
  int c = 0;
  vector<bool> isPrime(n + 1, true);
  isPrime[0] = isPrime[1] = 0;
  for (long long i = 2; i * i <= n; i++)
    if (isPrime[i])
      for (long long j = i * 2; j <= n; j += i) isPrime[j] = 0;
  for (int i = 0; i < n + 1; i++)
    if (isPrime[i]) c++;
  return c;
}
