#include <bits/stdc++.h>
using namespace std;
int q, sq, ctr, lens;
string s, res;
bool check() {
  int lenr = res.size();
  string wynik;
  for (int i = 0; i < lenr; i++) {
    if (res[i] == 'H')
      wynik += 'H';
    else
      for (int j = 0; j < lenr; j++) wynik += res[j];
    if (wynik.size() > 1000 * 1000) break;
  }
  return wynik == s;
}
int main() {
  cin >> s;
  lens = s.size();
  for (int i = 0; i < lens; i++)
    if (s[i] == 'Q') q++;
  if (q == 0) {
    printf("Yes\n");
    return 0;
  }
  sq = sqrt(q);
  if (sq * sq != q) {
    printf("No\n");
    return 0;
  }
  for (int i = 0; i < lens; i++) {
    if (s[i] == 'Q') break;
    ctr++;
  }
  if (ctr & 1) {
    printf("No\n");
    return 0;
  }
  for (int i = 0; i < ctr / 2; i++) res += 'H';
  for (int i = ctr; i < lens && sq; i++) {
    if (s[i] == 'Q') sq--;
    res += s[i];
  }
  ctr = 0;
  for (int i = lens - 1; s[i] != 'Q'; i--) ctr++;
  if (ctr & 1) {
    printf("No\n");
    return 0;
  }
  for (int i = 0; i < ctr / 2; i++) res += 'H';
  if (check()) {
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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 q, sq, ctr, lens;
string s, res;
bool check() {
  int lenr = res.size();
  string wynik;
  for (int i = 0; i < lenr; i++) {
    if (res[i] == 'H')
      wynik += 'H';
    else
      for (int j = 0; j < lenr; j++) wynik += res[j];
    if (wynik.size() > 1000 * 1000) break;
  }
  return wynik == s;
}
int main() {
  cin >> s;
  lens = s.size();
  for (int i = 0; i < lens; i++)
    if (s[i] == 'Q') q++;
  if (q == 0) {
    printf("Yes\n");
    return 0;
  }
  sq = sqrt(q);
  if (sq * sq != q) {
    printf("No\n");
    return 0;
  }
  for (int i = 0; i < lens; i++) {
    if (s[i] == 'Q') break;
    ctr++;
  }
  if (ctr & 1) {
    printf("No\n");
    return 0;
  }
  for (int i = 0; i < ctr / 2; i++) res += 'H';
  for (int i = ctr; i < lens && sq; i++) {
    if (s[i] == 'Q') sq--;
    res += s[i];
  }
  ctr = 0;
  for (int i = lens - 1; s[i] != 'Q'; i--) ctr++;
  if (ctr & 1) {
    printf("No\n");
    return 0;
  }
  for (int i = 0; i < ctr / 2; i++) res += 'H';
  if (check()) {
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
  return 0;
}

```