#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  string a;
  cin >> a;
  int n = 0, m = 0, first = 0, last = 0;
  bool b = true;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == 'H') n++;
    if (a[i] == 'Q') m++;
  }
  int sm = int(sqrt(m));
  int i = 0;
  i = a.size() - 1;
  while ((i >= 0) && (a[i] == 'H')) {
    last++;
    i--;
  };
  last /= 2;
  i = 0;
  while ((i < a.size()) && (a[i] == 'H')) {
    first++;
    i++;
  };
  first /= 2;
  if (m == 0)
    cout << "Yes";
  else {
    if (!((sm * sm == m) && (n % (sm + 1) == 0)))
      cout << "No";
    else {
      string middle = "";
      int counter = 0;
      while (counter < sm) {
        if (a[i] == 'Q') counter++;
        middle += a[i];
        i++;
      }
      string str;
      str = middle;
      for (int i = 0; i < first; i++) {
        str = 'H' + str;
      }
      for (int i = 0; i < last; i++) {
        str = str + 'H';
      }
      string out = "";
      for (int i = 0; i < str.size(); i++) {
        if (str[i] == 'H')
          out = out + "H";
        else
          out += str;
      };
      if (out == a)
        cout << "Yes";
      else
        cout << "No";
    };
  }
  return EXIT_SUCCESS;
}
