The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...

Input

The only line of the input is a string between 1 and 106 characters long.

Output

Output "Yes" or "No".

Examples

Input

HHHH


Output

Yes


Input

HQHQH


Output

No


Input

HHQHHQH


Output

No


Input

HHQQHHQQHH


Output

Yes

Note

The rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Fish <lyhypacm@gmail.com>
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        String s = in.next();
        out.println(sol(s.toCharArray()) ? "Yes" : "No");
    }

    private boolean sol(char[] s) {
        int countH = 0, countQ = 0;
        for (char value : s) {
            if (value == 'H')
                ++countH;
            else
                ++countQ;
        }
        if (countQ == 0) {
            return true;
        } else {
            int q = Numeric.sqrt(countQ);
            if (q * q != countQ)
                return false;
            if (countH % (q + 1) != 0)
                return false;
            int h = countH / (q + 1);
            int n = h + q, start = 0, end = s.length;
            for (int i = 0; i < s.length; ++i) {
                if (s[i] == 'Q') {
                    if (i % 2 == 1)
                        return false;
                    start = i / 2;
                    end = start + n - 1;
                    break;
                }
            }
            int idx = 0;
            for (int i = start; i <= end; ++i) {
                if (s[i] == 'H') {
                    if (s[idx] != 'H')
                        return false;
                    ++idx;
                } else {
                    for (int j = start; j <= end; ++j) {
                        if (s[idx] != s[j])
                            return false;
                        ++idx;
                    }
                }
            }
            return true;
        }
    }
}

class InputReader {
    private Scanner scanner;

    public InputReader(InputStream inputStream) {
        scanner = new Scanner(new BufferedReader(new InputStreamReader(inputStream)));
    }

    public int nextInt() {
        return scanner.nextInt();
    }

    public long nextLong() {
        return scanner.nextLong();
    }

    public String next() {
        return scanner.next();
    }

    public BigInteger nextBigInteger() {
        return scanner.nextBigInteger();
    }

    public BigDecimal nextBigDecimal() {
        return scanner.nextBigDecimal();
    }

    public double nextDouble() {
        return scanner.nextDouble();
    }
}

class OutputWriter {
    private PrintWriter printWriter;

    public OutputWriter(OutputStream outputStream) {
        printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        printWriter = new PrintWriter(writer);
    }

    public <T> void print(T object) {
        printWriter.print(object);
    }

    public <T> void println(T object) {
        printWriter.println(object);
    }

    public void println() {
        printWriter.println();
    }

    public void close() {
        printWriter.close();
    }
}

class Numeric {
    public static long exp(long x, long k, long MOD) {
        long result = 1;
        x %= MOD;

        while (k > 0) {
            if ((k & 1) != 0)
                result = result * x % MOD;
            x = x * x % MOD;
            k >>= 1;
        }

        return result;
    }

    public static int sqrt(int n) {
        int ret = Math.max(0, (int) Math.sqrt(n) - 2);
        while (ret * ret <= n)
            ++ret;
        return ret - 1;
    }
}
