#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 1e2 + 10;
int main() {
  string str;
  cin >> str;
  int fq = str.find("Q");
  if (fq == string::npos) {
    cout << "Yes" << endl;
    return 0;
  }
  fq /= 2;
  int noq = count(str.begin(), str.end(), 'Q');
  int nq = sqrt(noq);
  int nh = (str.size() - noq) / (nq + 1);
  string a = str.substr(fq, nh + nq);
  string t;
  for (int i = 0; i < int(a.size()); i++) {
    if (a[i] == 'H')
      t += "H";
    else
      t += a;
  }
  cout << (str == t ? "Yes" : "No");
  return 0;
}
