#include <bits/stdc++.h>
using namespace std;
char s[1000010];
char ts[1000010];
char ans[1000010];
bool ck(char *ss) {
  int cntt = 0;
  int len = strlen(ss);
  for (int i = 0; ss[i]; i++) {
    if (ss[i] == 'H')
      ts[cntt++] = 'H';
    else {
      for (int j = 0; j < len; j++) {
        ts[cntt++] = ss[j];
        if (cntt > 1000000) return false;
      }
    }
    if (cntt > 1000000) return false;
  }
  ts[cntt] = 0;
  return true;
}
int main() {
  while (scanf("%s", s) == 1) {
    int hs = 0, qs = 0;
    for (int i = 0; s[i]; i++)
      if (s[i] == 'H')
        hs++;
      else
        qs++;
    int x = (int)(sqrt(qs * 1.0) + 1e-8);
    if (x * x != qs) {
      puts("No");
      continue;
    }
    if (x == 0) {
      puts("Yes");
      continue;
    }
    int q = x;
    if (hs % (x + 1) != 0) {
      puts("No");
      continue;
    }
    int h = hs / (x + 1);
    int preh = 0, pos = 0;
    while (s[pos] != 'Q') {
      preh++;
      pos++;
    }
    pos /= 2;
    preh /= 2;
    if (preh > h) {
      puts("No");
      continue;
    }
    preh = 0;
    int cntt = 0;
    int preq = 0, pre = pos;
    while (s[pos] && (preh != h || preq != q)) {
      if (s[pos] == 'H')
        preh++;
      else
        preq++;
      pos++;
    }
    for (int i = pre; i < pos; i++) ans[cntt++] = s[i];
    ans[cntt] = 0;
    if (!ck(ans)) {
      puts("No");
      continue;
    }
    if (strcmp(ts, s) == 0)
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
