#include <bits/stdc++.h>
char slowo[1000006];
char kod[1000006];
int z, h, q;
bool wys() {
  for (int i = 0; kod[i] != 0; i++)
    if (kod[i] != slowo[z++]) {
      return 0;
    }
  return 1;
}
bool mozna() {
  for (int i = 0; kod[i] != 0; i++) {
    if (kod[i] == 'H') {
      if (slowo[z++] != 'H') {
        return 0;
      }
    } else if (!wys())
      return 0;
  }
  return 1;
}
bool check() {
  int H = 0, Q = 0, pos = -1;
  scanf("%s", slowo);
  for (int i = 0; slowo[i] != 0; i++) {
    if (slowo[i] == 'H')
      H++;
    else {
      Q++;
      if (pos == -1) pos = i;
    }
  }
  q = sqrt(Q);
  if (q * q != Q) {
    return 0;
  }
  h = H / (q + 1);
  if (h * (q + 1) != H) {
    return 0;
  }
  if (pos < 0) return 1;
  if (pos % 2) {
    return 0;
  }
  for (int i = 0; i < h + q; i++) kod[i] = slowo[i + pos / 2];
  if (mozna())
    return 1;
  else
    return 0;
}
int main() {
  if (check())
    printf("Yes\n");
  else
    printf("No\n");
}
