#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
char a[10005];
int main()
{
	
	int len = 0, flag=0;
	cin >> a;
	len = strlen(a);
	for(int i = 0; i < len; i++)
	{
		if(a[i] == 'H' || a[i] == 'Q' || a[i] == '9')
		{
			flag = 1;
		}
		else flag = 0;
		
		
	}
	if(flag == 1)
	{
		cout<<"YES"<<endl;
	} 
	else cout<<"NO"<<endl;
	return 0;
}