#include <bits/stdc++.h>
using namespace std;
template <class P, class Q>
void smin(P &a, Q b) {
  if (b < a) a = b;
}
template <class P, class Q>
void smax(P &a, Q b) {
  if (b > a) a = b;
}
template <class P, class Q>
bool in(const P &a, const Q &b) {
  return a.find(b) != a.end();
}
void ans(bool x) {
  cout << (x ? "Yes" : "No") << endl;
  exit(0);
}
int main() {
  string s;
  cin >> s;
  if (count((s).begin(), (s).end(), 'Q')) {
    for (int i = s.find('Q') / 2, qc = 0, len = 0; i < ((int)(s).size()); i++) {
      len++;
      if (s[i] == 'Q') qc++;
      if (len - qc + 1LL * qc * len == ((int)(s).size())) {
        string sc = s.substr(s.find('Q') / 2, len), g;
        for (__typeof((sc).begin()) it = (sc).begin(); it != (sc).end(); ++it)
          g += *it == 'H' ? string("H") : sc;
        ans(s == g);
      }
    }
    ans(false);
  } else
    ans(true);
  return 0;
}
