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.
#include <bits/stdc++.h>
using namespace std;
void Get(int &T) {
  char C;
  bool F = 0;
  for (; C = getchar(), C < '0' || C > '9';)
    if (C == '-') F = 1;
  for (T = C - '0'; C = getchar(), C >= '0' && C <= '9'; T = T * 10 + C - '0')
    ;
  F && (T = -T);
}
char S[1000005];
char Str[1000005];
char S2[1000005];
int K;
int M, N;
void Init() {
  gets(S + 1);
  M = strlen(S + 1);
}
int Le, Ri;
int mQ, mH;
int nQ, nH;
int First;
void Work() {
  for (int i = 1; i <= M; i++)
    if (S[i] == 'Q')
      mQ++;
    else
      mH++;
  nQ = sqrt(mQ) + (1e-6);
  if (nQ * nQ != mQ) {
    puts("No");
    exit(0);
  }
  if (mH % (1 + nQ) != 0) {
    puts("No");
    exit(0);
  }
  nH = mH / (1 + nQ);
  for (int i = M; i >= 1; i--)
    if (S[i] == 'Q') First = i;
  if (First == 0) return;
  First--;
  if (First & 1) {
    puts("No");
    exit(0);
  }
  First >>= 1;
  N = nQ + nH;
  for (int i = 1; i <= N; i++) Str[i] = S[i + First];
  for (int i = 1; i <= N; i++) {
    if (Str[i] == 'H')
      S2[++K] = 'H';
    else {
      for (int j = 1; j <= N; j++) S2[++K] += Str[j];
    }
  }
  if (strcmp(S2 + 1, S + 1) != 0) {
    puts("No");
    exit(0);
  }
}
void Output() { puts("Yes"); }
int main() {
  Init();
  Work();
  Output();
  return 0;
}
