#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> s;
  int n = ((int)(s).size());
  int q = 0;
  for (int i = 0; i < (n); i++) q += s[i] == 'Q';
  int r = 0;
  while (r * r < q) r++;
  if (r * r != q) return cout << "No" << endl, 0;
  if (r == 0) return cout << "Yes" << endl, 0;
  string t;
  int cur = 0;
  while (s[cur] != 'Q') cur++;
  if (cur % 2) return cout << "No" << endl, 0;
  for (int i = 0; i < (cur / 2); i++) t += 'H';
  t += 'Q';
  cur++;
  for (int i = 0; i < (r - 1); i++) {
    while (s[cur] != 'Q') cur++, t += 'H';
    t += 'Q';
    cur++;
  }
  cur = n - 1;
  while (s[cur] != 'Q') cur--;
  if ((n - 1 - cur) % 2) return cout << "No" << endl, 0;
  for (int i = 0; i < ((n - 1 - cur) / 2); i++) t += 'H';
  string res;
  for (int i = 0; i < (((int)(t).size())); i++) {
    if (t[i] == 'H')
      res += 'H';
    else
      res += t;
  }
  cout << (res == s ? "Yes" : "No") << endl;
}
