The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...
The only line of the input is a string between 1 and 10<sup class="upper-index">6</sup> characters long.
char = str(input("The chars\n"))
o = 1
e = 0
t = len(char) - 1
y = len(char) - 1
if 1 <= len(char) <= 1000000 and not (len(char) % 2 == 0):
    while 'H' or 'Q' in char:
        if char[e] + char[o] == "HQ" and char[t] == 'Q' or char[t] == 'H':
            print("No")
        else:
            print("Yes")
        o = o + 1
        e = e + 1
        break

if 1 <= len(char) <= 1000000 and len(char) % 2 == 0:
    while 'H' or 'Q' in char:
        if char[e] + char[o] == "HQ":
            print("NO")
        if char[e] + char[o] == "HH" or char[e] + char[o] == "QQ" or char[e] + char[o] == "QH":
            print("Yes")
        o = o + 1
        e = e + 1
        break
