#include <bits/stdc++.h>
const int _MAX_N = 1e6 + 1;
int k;
int i_q;
int p_q[2];
int i_h[2];
char ciag_ds[_MAX_N + 1];
char ciag_u[_MAX_N];
char ciag_p[_MAX_N + 1];
int main() {
  scanf(" %s", ciag_ds);
  int l = strlen(ciag_ds);
  p_q[0] = -1;
  for (int i = 0; i < l; i++) {
    if (ciag_ds[i] == 'Q') {
      i_h[1] = 0;
      if (p_q[0] == -1) p_q[0] = i;
      p_q[1] = i;
      i_q++;
    } else {
      if (p_q[0] == -1)
        i_h[0]++;
      else
        i_h[1]++;
    }
  }
  if (i_q == 0) {
    printf("Yes\n");
    return 0;
  }
  k = sqrt(i_q);
  if (i_h[0] % 2 || i_h[1] % 2) {
    printf("No\n");
    return 0;
  }
  if (k * k != i_q) {
    printf("No\n");
    return 0;
  }
  int j = 0;
  for (j = 0; j < (i_h[0] / 2); j++) ciag_u[j] = 'H';
  int i_aq = 0;
  for (int i = p_q[0]; i_aq < k; i++) {
    ciag_u[j++] = ciag_ds[i];
    if (ciag_ds[i] == 'Q') i_aq++;
  }
  for (int i = 0; i < (i_h[1] / 2); i++) ciag_u[j++] = 'H';
  int i = 0;
  for (int p = 0; p < j; p++) {
    if (ciag_u[p] == 'H')
      ciag_p[i++] = 'H';
    else {
      for (int o = 0; o < j; o++) ciag_p[i++] = ciag_u[o];
    }
  }
  if (i != l) {
    printf("No\n");
    return 0;
  }
  for (int p = 0; p < i; p++) {
    if (ciag_p[p] != ciag_ds[p]) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
