#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string out;
  cin >> out;
  int ileq = 0;
  for (auto c : out)
    if (c == 'Q') ileq++;
  if (ileq == 0) {
    cout << "Yes\n";
    return 0;
  }
  int nq = sqrt(ileq);
  if (1.0 * nq != 1.0 * sqrt(ileq)) {
    cout << "No\n";
    return 0;
  }
  int nh = ((int)(out).size() - ileq) / (nq + 1);
  int prefh = 0;
  for (int i = 0; i < (int)(out).size() && out[i] == 'H'; i++) prefh++;
  int sufh = 0;
  for (int i = (int)(out).size() - 1; i >= 0 && out[i] == 'H'; i--) sufh++;
  if (sufh & 1 || prefh & 1) {
    cout << "No\n";
    return 0;
  }
  prefh /= 2;
  sufh /= 2;
  int j = 0, cnt = 0;
  for (int i = 0; i < (int)(out).size(); i++) {
    if (out[i] == 'Q') cnt++;
    if (cnt == nq) {
      j = i;
      break;
    }
  }
  string org = out.substr(prefh, j - prefh + sufh + 1);
  string sure;
  cnt = 0;
  for (auto c : org)
    if (c == 'H') cnt++;
  if (nh != cnt) {
    cout << "No\n";
    return 0;
  }
  for (int i = 0; i < (int)(org).size(); i++) {
    if (org[i] == 'H')
      sure += 'H';
    else
      sure += org;
  }
  if (out == sure)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
