#include <bits/stdc++.h>
using namespace std;
string a, ans, jie;
int la, lh, lq, h, q, lans, wei[1000001];
int main() {
  cin >> a;
  la = a.size();
  for (int i = 0; i < la; i++) {
    if (a[i] == 'H')
      lh++;
    else {
      lq++;
      wei[lq] = i;
    }
  }
  q = sqrt(lq);
  if (q * q != lq) {
    cout << "No";
    return 0;
  }
  h = lh / (q + 1);
  if (h * q + h != lh) {
    cout << "No";
    return 0;
  }
  if (lq == 0) {
    if (lh % 2 == 1)
      cout << "No";
    else
      cout << "Yes";
    return 0;
  }
  lans = q + h;
  if (wei[1] % 2 != 0) {
    cout << "No";
    return 0;
  }
  for (int i = 1; i <= wei[1] / 2; i++) {
    ans = ans + 'H';
  }
  for (int i = wei[1]; i <= wei[q]; i++) {
    ans = ans + a[i];
  }
  int o = la - 1 - wei[lq];
  if (o % 2 != 0) {
    cout << "No";
    return 0;
  }
  for (int i = 1; i <= o / 2; i++) {
    ans = ans + 'H';
  }
  for (int i = 0; i < lans; i++) {
    if (ans[i] == 'H')
      jie = jie + 'H';
    else
      jie = jie + ans;
  }
  if (jie == a)
    cout << "Yes";
  else
    cout << "No";
}
