The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...

Input

The only line of the input is a string between 1 and 106 characters long.

Output

Output "Yes" or "No".

Examples

Input

HHHH


Output

Yes


Input

HQHQH


Output

No


Input

HHQHHQH


Output

No


Input

HHQQHHQQHH


Output

Yes

Note

The rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.
from collections import Counter
import re

def issquare(n):
    return round(n**0.5)**2==n

def check_orig(code):
    counts = Counter(code)
    orig = ''
    if not issquare(counts['Q']):
        return ''
    nq = round(counts['Q']**0.5)
    if counts['H']%(nq+1) != 0:
        return ''
    nh = counts['H']//(nq+1)
    st = 0
    while st<len(code) and code[st]=='H':
        st+=1
    if st%2!=0:
        return ''
    orig+='H'*(st//2) 
    if st==len(code):
        return orig*2
    end = -1
    while code[end]=='H':
        end-=1
    if end%2!=1:
        return ''
    orig_end = 'H'*(abs(end+1)//2)
    qcount = 0
    while qcount<nq:
        if st>=len(code):
            return ''
        orig+=code[st]
        if code[st]=='Q':
            qcount+=1
        st+=1
        
    orig+=orig_end
    return orig
    
def is_real(code,orig):
    ci = 0
    l = len(orig)
    for oi,letter in enumerate(orig):
        if letter=='H':
            if code[ci]!=letter:
                return False
            ci+=1
        elif letter=='Q':
            if code[ci:ci+l]!=orig:
                return False
            ci+=l
    return ci==len(code)
    
code = input()
orig = check_orig(code)

if not orig:
    print("No")

elif is_real(code,orig):
    print("Yes")
else:
    print("No")
    
        
    


        