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.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class e {
    void do_solve() {
        String S = nextToken();
        char s[] = S.toCharArray();
        int n = s.length;
        int qq = 0;
        
        for(int i = 0; i < n; i++) {
            if (s[i] == 'Q') {
                qq++;
            }
        }
        
        int q = 0;
        while (q * q < qq) {
            q++;
        }
        if (q * q != qq || (n - qq) % (q + 1) != 0) {
            out.println("No");
            return;
        }
        int len = (n - qq) / (q + 1) + q;
        
        int hbegin = 0;
        for(int i = 0; i < n; i++) {
            if ((i == 0 && s[0] == 'H') || (i > 0 && s[i] == s[i - 1])) {
                hbegin++;
            } else {
                break;
            }
        }
        if (q > 0 && hbegin % 2 != 0) {
            out.println("No");
            return;
        }
        boolean ok = true;
        if (q > 0) {
            hbegin /= 2;
            char[] ini = S.substring(hbegin, hbegin + len).toCharArray();

            int i = 0, t = 0;
            for(i = 0; i < len && ok && t < n; i++) {
                if (ini[i] == 'H') {
                    ok &= s[t++] == 'H';
                } else {
                    for(int j = 0; j < len && ok && t < n; j++) {
                        ok &= s[t++] == ini[j];
                    }
                }
            }
            
            ok &= t == n && i == len; 
        }
        out.println(ok ? "Yes" : "No");
    }

    void mainProgram() {
        init(null);
        int test = 0;
        long T = System.currentTimeMillis();
        do_solve();
        System.err.println("Time on test " + (test++) + ": "
                + (System.currentTimeMillis() - T) + " ms");
        out.close();
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    void init(String filename) {
        Locale.setDefault(Locale.US);
        if (filename != null)
            try {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            } catch (Exception e) {
                e.printStackTrace();
                filename = null;
            }
        if (filename == null) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
        st = new StringTokenizer("");
    }

    static BufferedReader in;
    static StringTokenizer st = new StringTokenizer("");
    static PrintWriter out;
    static long systemTime;

    public static void main(String[] args) {
        try {
            setTime();
            new e().mainProgram();
            printTime();
            printMemory();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static void setTime() {
        systemTime = System.currentTimeMillis();
    }

    static void printTime() {
        System.err.println("Time consumed: "
                + (System.currentTimeMillis() - systemTime));
    }

    static void printMemory() {
        System.err.println("Memory consumed: "
                + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime()
                        .freeMemory()) / 1000 + "kb");
    }

    boolean hasMoreTokens() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(in.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return st.hasMoreTokens();
    }

    String nextToken() {
        return hasMoreTokens() ? st.nextToken() : null;
    }

    Integer nextInt() {
        return Integer.parseInt(nextToken());
    }

    Double nextDouble() {
        return Double.parseDouble(nextToken());
    }

    Long nextLong() {
        return Long.parseLong(nextToken());
    }

    BigInteger add(BigInteger A, BigInteger B) {
        return A.add(B);
    }

    BigInteger mult(BigInteger A, BigInteger B) {
        return A.multiply(B);
    }

    BigInteger sub(BigInteger A, BigInteger B) {
        return A.subtract(B);
    }

    BigInteger div(BigInteger A, BigInteger B) {
        return A.divide(B);
    }

    BigInteger mi(BigInteger A) {
        return (BigInteger.ZERO).subtract(A);
    }

    BigInteger sq(BigInteger A) {
        return A.multiply(A);
    }

    BigInteger val(long a) {
        return BigInteger.valueOf(a);
    }

    int cmp(BigInteger a, BigInteger b) {
        return a.compareTo(b);
    }

    BigInteger gcd(BigInteger a, BigInteger b) {
        if (cmp(a, val(0)) < 0)
            a = mi(a);
        if (cmp(b, val(0)) < 0)
            b = mi(b);
        return a.gcd(b);
    }
}
