#include <bits/stdc++.h>
using namespace std;
const string yes = "Yes", no = "No";
bool HQ(string s1, string s2) {
  string str = "";
  for (int i = 0; i < s1.length(); i++) {
    if (s1[i] == 'H')
      str += 'H';
    else {
      str += s1;
    }
  }
  if (str == s2) return true;
  return false;
}
int main() {
  string s;
  long long qwq = 0, hwh = 0, sum1 = 0, nowq = 0;
  bool ft = 0;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'Q') {
      ft = 1;
      qwq++;
      nowq = i;
    } else
      hwh++;
    if (!ft) sum1++;
  }
  string guess(sum1 / 2, 'H');
  long long sqqwq = (long long)(sqrt(qwq));
  long long sqwq = sqqwq;
  nowq = s.length() - nowq - 1;
  for (int i = sum1; i < s.length() && (sqwq != 0); i++) {
    if (s[i] == 'Q') sqwq--;
    guess += s[i];
  }
  string solo_str(nowq / 2, 'H');
  guess += solo_str;
  if (qwq == 0)
    cout << yes;
  else if (sqqwq * sqqwq != qwq || sum1 % 2 != 0 || nowq % 2 != 0)
    cout << no;
  else if (HQ(guess, s))
    cout << yes;
  else
    cout << no;
  return 0;
}

### Prompt

Please formulate a CPP solution to 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;
const string yes = "Yes", no = "No";
bool HQ(string s1, string s2) {
  string str = "";
  for (int i = 0; i < s1.length(); i++) {
    if (s1[i] == 'H')
      str += 'H';
    else {
      str += s1;
    }
  }
  if (str == s2) return true;
  return false;
}
int main() {
  string s;
  long long qwq = 0, hwh = 0, sum1 = 0, nowq = 0;
  bool ft = 0;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'Q') {
      ft = 1;
      qwq++;
      nowq = i;
    } else
      hwh++;
    if (!ft) sum1++;
  }
  string guess(sum1 / 2, 'H');
  long long sqqwq = (long long)(sqrt(qwq));
  long long sqwq = sqqwq;
  nowq = s.length() - nowq - 1;
  for (int i = sum1; i < s.length() && (sqwq != 0); i++) {
    if (s[i] == 'Q') sqwq--;
    guess += s[i];
  }
  string solo_str(nowq / 2, 'H');
  guess += solo_str;
  if (qwq == 0)
    cout << yes;
  else if (sqqwq * sqqwq != qwq || sum1 % 2 != 0 || nowq % 2 != 0)
    cout << no;
  else if (HQ(guess, s))
    cout << yes;
  else
    cout << no;
  return 0;
}

```