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.
import os, sys
 
isLocal = os.environ.get('USER', '') == 'xueenpeng'
if isLocal:
    # sys.stdin = open(r"./file/input.txt", 'r')
    # sys.stdout = open(r"./file/output.txt", 'w')
    pass
 
input = sys.stdin.readline
 
def main():
    s = input()
    last = -1
    for index, ch in enumerate(s):
        if ch == 'Q':
            if last == -1:
                last = index
            else:
                if 0 < index - last <= 2:
                    print("No")
                    return
                last = -1
    if last == -1:
        print("Yes")
    else:
        print('No')
main()