def hqn(s):
    lst = [i for  i in s if i in "HQ9"]
    return "YES" if len(lst) > 0 else "NO"
    
if __name__ == '__main__':
    s = str(input())
    print(hqn(s))
f329c18fc0890620dbe07d30d57aa90f0cbd794e
<mask token>

def hqn(s):
    lst = [i for i in s if i in 'HQ9']
    return 'YES' if len(lst) > 0 else 'NO'


<mask token>

def hqn(s):
    lst = [i for i in s if i in 'HQ9']
    return 'YES' if len(lst) > 0 else 'NO'


if __name__ == '__main__':
    s = str(input())
    print(hqn(s))

def hqn(s):
    lst = [i for  i in s if i in "HQ9"]
    return "YES" if len(lst) > 0 else "NO"
    
if __name__ == '__main__':
    s = str(input())
    print(hqn(s))