#include <bits/stdc++.h>
using namespace std;
int i, j;
int main() {
  stack<char> S;
  string t;
  cin >> t;
  int q = 0, h = 0;
  for (i = 0; i < t.size(); i++) {
    if (t[i] == 'Q')
      q++;
    else
      h++;
  }
  if (q == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  int q1 = q, h1 = h, h2 = 0;
  bool b = 0;
  for (i = 0; i < t.size(); i++) {
    if (t[i] == 'Q') {
      break;
    } else
      h2++;
  }
  if (h2 % 2) {
    cout << "No\n";
    return 0;
  }
  if (q != ((int)sqrt(q)) * ((int)sqrt(q))) {
    cout << "No\n";
    return 0;
  }
  if (h % ((int)sqrt(q) + 1)) {
    cout << "No\n";
    return 0;
  }
  int len = (int)sqrt(q) + h / ((int)sqrt(q) + 1);
  string good;
  for (int j = i - h2 / 2; j < i - h2 / 2 + len; j++) {
    good.push_back(t[j]);
  }
  string code;
  for (int i = 0; i < len; i++) {
    if (good[i] == 'H')
      code.push_back('H');
    else {
      code += good;
    }
  }
  if (code == t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
