#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> s;
  int n = ((int)(s).size());
  int q = 0;
  for (int i = 0; i < (n); i++) q += s[i] == 'Q';
  int r = 0;
  while (r * r < q) r++;
  if (r == 0) return cout << "Yes" << endl, 0;
  int cur = 0;
  while (s[cur] != 'Q') cur++;
  string t = s.substr(cur / 2, r + (n - q) / (r + 1));
  string res;
  for (int i = 0; i < (((int)(t).size())); i++) {
    if (t[i] == 'H')
      res += 'H';
    else
      res += t;
  }
  cout << (res == s ? "Yes" : "No") << endl;
}
