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.util.regex.Pattern;
import java.util.regex.Matcher;

public class E_HQ {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        sc.close();
        System.out.println(judge(input));
    }

    static String judge(String input) {
        Pattern p = Pattern.compile("^H*");
        Matcher m = p.matcher(input);
        m.find();
        if (input.equals("Q")) {
            return "Yes";
        }

        String first = m.group(0);
        // There is no Q, return now
        if (input.equals(first)) {
            return "Yes";
        }

        // Match pattenr HH..HQ[X], H must be even.
        if ((first.length() % 2) == 1) {
            return "No";
        }

        first = first.substring(0, first.length() / 2);

        // Now try to find out [X] part.
        int qCounter = 0;
        for (int i = 0; i < input.length(); i++) {
            if (input.charAt(i) == 'Q') {
                qCounter++;
            }
        }
        // Source code should have exactly N Qs, where N^N = qCounter.
        // qCounter can only by be exactly i^2
        // Since the input is from 1 ~ 10^6, i < 1000
        int qSize = 0;
        for (int i = 1; i <= 1001; i++) {
           if(qCounter == i*i) {
               qSize = i;
               break;
           }
        }

        if(qSize == 0) {
            return "No";
        }

        int foundQ = 0;
        int lastQPos = 0;
        for (int i = 0; i < input.length() && foundQ < qSize; i++) {
            if (input.charAt(i) == 'Q') {
                lastQPos = i;
                foundQ++;
            }
        }
        int endOfSource = input.indexOf(first + "Q", lastQPos + 1);
        for (int i = lastQPos; i <= endOfSource; i++) {
            String source = input.substring(first.length(), i);
            if (input.equals(hg(source))) {
                return "Yes";
            }
        }
        return "No";
    }

    static String hg(String source) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < source.length(); i++) {
            switch (source.charAt(i)) {
                case 'H':
                    sb.append('H');
                    break;
                case 'Q':
                    sb.append(source);
                    break;
                default:
                    break;
            }
        }
        return sb.toString();
    }
}