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.
c = str(input())
o = 1
e = 0
t = len(c) - 1
y = len(c)
print(len(c))
if 1000000 >= len(c) >= 1 and (len(c) % 2 != 0) and (c[t] == "H" or c[t] == "Q"):  # odd
    while y >= 0:
        if c[e] + c[o] == "HQ":
            print("No")
            break
        e = e + 2
        o = o + 2
        y = y - 1
if 1000000 >= len(c) >= 1 and (len(c) % 2 == 0) and (c[t] == "H" or c[t] == "Q"):  # even
    while y >= 0 and (e != len(c) and o != len(c)):
        if c[e] + c[o] == "HQ":
            print("No")
            break
        e = e + 2
        o = o + 2
        y = y - 1


print("yes")
