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())
o = 1
e = 0
t = len(char) - 1
y = len(char) - 1
if 1 <= len(char) <= 1000000 and not (len(char) % 2 == 0) and not (len(char) == 1):
    while 'H' in char and 'Q' in char:
        if char[e] + char[o] == "HQ" and char[t] == 'Q' or char[t] == 'H':
            print("No")
        elif not (char[e] + char[o] == "HQ") and char[t] == 'Q' or char[t] == 'H':
            print("Yes")
        e = e + 2
        o = o + 2
        if e == o == t:
            break
        break
if 1 <= len(char) <= 1000000 and len(char) % 2 == 0 and not (len(char) == 1):
    while 'Q' in char and 'H' in char:
        if char[e] + char[o] == "HQ":
            print("NO")
        else:
            if not (char[e] + char[o] == "HQ") and char[y] == "H" or char[y] == "Q":
                print("Yes")
        e = e + 2
        o = o + 2
        if e == o == y:
            break
        break
if 1 <= len(char) <= 1000000 and len(char) == 1:
    if 'Q' or 'H' in char and char[e] == 'Q' or char[e] == 'H':
        print("Yes")
if 1 <= len(char) <= 1000000 and not (len(char) % 2 == 0):
    while 'H' in char and not (len(char) == 1) and not ('Q' in char):
        if char[e] + char[o] == "HH" and char[t] == 'H':
            print("Yes")
            break
if 1 <= len(char) <= 1000000 and not (len(char) % 2 == 0):
    while 'Q' in char and not (len(char) == 1) and not ('H' in char):
        if char[e] + char[o] == "QQ" and char[t] == 'Q':
            print("Yes")
            break
if 1 <= len(char) <= 1000000 and (len(char) % 2 == 0) and not (len(char) == 1):
    while 'Q' in char and not ('H' in char):
        if char[e] + char[o] == "QQ":
            print("Yes")
            break
if 1 <= len(char) <= 1000000 and (len(char) % 2 == 0) and not (len(char) == 1):
    while 'H' in char and not ('Q' in char):
        if char[e] + char[o] == "HH":
            print("Yes")
            break
