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.
a = input()
b = []
h = ''
c = 0
for i in a:
	if i == 'Q':
		c += 1
if c == 0:
	print('Yes')
	exit(0)
r = -1
for i in range(1001):
	if i*i == c:
		r = i
		break
c = [len(a.split('Q')[0])//2, len(a.split('Q')[-1])//2]
resp = ''
d = 0
for i in a:
	if i == 'Q':
		d += 1
	if d != 0:
		resp += i
	if d == r:
		break

resp = 'H'*c[0] + resp + 'H'*c[1]

def hq(a):
	resp = ''
	for i in a:
		if i == 'H':
			resp += 'H'
		else:
			resp += a
	return resp

if a == hq(resp):
	print('Yes')
else:
	print('No')
