#include <bits/stdc++.h>
using namespace std;
int genopstr(string &src, string &dst) {
  int iter1;
  for (iter1 = 0; iter1 < src.size(); ++iter1) {
    if (src[iter1] == 'H')
      dst = dst.append(1, 'H');
    else
      dst.append(src);
  }
}
int testopstr(string &s) {
  int r = 0, cnt, cnth = 0, cntq = 0, nh, nq, iter1, h0 = 0, ns;
  char ch;
  for (iter1 = 0; iter1 < s.size() && s[iter1] == 'H'; ++iter1) {
    ++cnth;
    ++h0;
  }
  for (; iter1 < s.size(); ++iter1) {
    if (s[iter1] == 'H')
      ++cnth;
    else if (s[iter1] == 'Q')
      ++cntq;
  }
  if (cntq == 0) return true;
  cnt = cnth + cntq;
  nq = (int)(sqrt((double)cntq));
  if (nq * nq != cntq) return false;
  nh = cnth / (nq + 1);
  if (nh > 0 && nh * (nq + 1) != cnth) return false;
  if (h0 % 2 != 0) return false;
  h0 /= 2;
  ns = nh + nq;
  string s2(s.begin() + h0, s.begin() + h0 + ns), s3;
  genopstr(s2, s3);
  if (s == s3)
    return true;
  else
    return false;
}
int main() {
  string s;
  cin >> s;
  std::transform(s.begin(), s.end(), s.begin(), ::toupper);
  bool r;
  r = testopstr(s);
  if (r)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

### Prompt

In Cpp, your task is to solve the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int genopstr(string &src, string &dst) {
  int iter1;
  for (iter1 = 0; iter1 < src.size(); ++iter1) {
    if (src[iter1] == 'H')
      dst = dst.append(1, 'H');
    else
      dst.append(src);
  }
}
int testopstr(string &s) {
  int r = 0, cnt, cnth = 0, cntq = 0, nh, nq, iter1, h0 = 0, ns;
  char ch;
  for (iter1 = 0; iter1 < s.size() && s[iter1] == 'H'; ++iter1) {
    ++cnth;
    ++h0;
  }
  for (; iter1 < s.size(); ++iter1) {
    if (s[iter1] == 'H')
      ++cnth;
    else if (s[iter1] == 'Q')
      ++cntq;
  }
  if (cntq == 0) return true;
  cnt = cnth + cntq;
  nq = (int)(sqrt((double)cntq));
  if (nq * nq != cntq) return false;
  nh = cnth / (nq + 1);
  if (nh > 0 && nh * (nq + 1) != cnth) return false;
  if (h0 % 2 != 0) return false;
  h0 /= 2;
  ns = nh + nq;
  string s2(s.begin() + h0, s.begin() + h0 + ns), s3;
  genopstr(s2, s3);
  if (s == s3)
    return true;
  else
    return false;
}
int main() {
  string s;
  cin >> s;
  std::transform(s.begin(), s.end(), s.begin(), ::toupper);
  bool r;
  r = testopstr(s);
  if (r)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

```