#include <bits/stdc++.h>
using namespace std;
string s;
int len;
int sumh, sumq;
int main() {
  getline(cin, s);
  len = s.size();
  for (int i = 0; i < len; i++)
    if (s[i] == 'H')
      sumh++;
    else
      sumq++;
  if (sumq == 0) {
    printf("Yes\n");
    return 0;
  }
  int g = (int)(sqrt(sumq));
  if (g * g != sumq) {
    printf("No\n");
    return 0;
  }
  int xx = sumh / (g + 1);
  if (xx * (g + 1) != sumh) {
    printf("No\n");
    return 0;
  }
  int len = g + xx;
  for (g = 0; s[g] != 'Q'; g++)
    ;
  if (g & 1) {
    printf("No\n");
    return 0;
  }
  string ne = s.substr(g / 2, len);
  string ans = "";
  int le = ne.size();
  for (int i = 0; i < le; i++)
    if (ne[i] == 'H')
      ans += "H";
    else
      ans += ne;
  if (ans == s)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
