#include <bits/stdc++.h>
using namespace std;
int N;
char S[1020202];
int judge(char *S) {
  int l, r;
  for (l = 1; S[l] == 'H'; l++)
    ;
  if (l == N + 1) return 1;
  if (~l & 1) return 0;
  l >>= 1;
  int h = 0, q = 0;
  for (r = l + 1; r <= N; r++) {
    if (S[r] == 'Q')
      q++;
    else
      h++;
    if (h + q * (r - l) == N)
      break;
    else if (h + q * (r - l) > N)
      return 0;
  }
  for (h = l + 1, q = 1; h <= r; h++)
    if (S[h] == 'H') {
      if (S[q] == 'H')
        q++;
      else
        return 0;
    } else {
      for (int j = 1; j <= r - l; j++) {
        if (S[l + j] != S[q]) return 0;
        q++;
      }
    }
  return 1;
}
int main() {
  scanf("%s", S + 1);
  for (N = 1; S[N]; N++)
    ;
  N--;
  if (judge(S))
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
