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.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class MainE {

    private FastScanner in;
    private PrintWriter out;

    public void solve() throws IOException {
        String output = in.next();
        int outputQFirst = -1;
        int outputQCount = 0;
        int outputHCount = 0;
        for (int i = 0; i < output.length(); i++) {
            if (output.charAt(i) == 'Q') {
                outputQCount++;
                if (outputQFirst == -1) {
                    outputQFirst = i;
                }
            }
        }
        outputHCount = output.length() - outputQCount;

        int programQCount = (int) Math.sqrt(outputQCount);
        if (programQCount * programQCount != outputQCount) {
            System.out.println("No");
            return;
        }

        int programHCount = outputHCount / (programQCount + 1);
        if (programHCount * (programQCount + 1) != outputHCount) {
            System.out.println("No");
            return;
        }

        if (outputQCount == 0) {
            System.out.println("Yes");
            return;
        }

        if (outputQFirst % 2 == 1) {
            System.out.println("No");
            return;
        }

        byte[] outputBytes = output.getBytes();
        byte[] programBytes = new byte[programHCount + programQCount];
        System.arraycopy(outputBytes, outputQFirst / 2, programBytes, 0,
                        programHCount + programQCount);

        int currentOutputPos = 0;
        for (int i = 0; i < programBytes.length; i++) {
            if (programBytes[i] == 'H') {
                if (outputBytes[currentOutputPos] != 'H') {
                    System.out.println("No");
                    return;
                }
                currentOutputPos++;
            }
            else {
                if (!isArrayEquals(outputBytes, currentOutputPos, programBytes,
                                0, programBytes.length)) {
                    System.out.println("No");
                    return;
                }
                currentOutputPos = currentOutputPos + programBytes.length;
            }
        }

        System.out.println("Yes");
        return;
    }

    private boolean isArrayEquals(byte[] a1, int pos1, byte[] a2, int pos2,
                    int length) {
        for (int i = 0; i < length; i++) {
            if (a1[pos1 + i] != a2[pos2 + i]) {
                return false;
            }
        }
        return true;
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            solve();
            out.close();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] arg) {
        new MainE().run();
    }
}
