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.InputStreamReader;
import java.util.ArrayList;
import java.util.List;


public class P290E_HQ {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        System.out.println(res(s) ? "Yes" : "No");
    }
    
    public static boolean res(String s) {
        List<Integer> l = new ArrayList<Integer>();
        int len = s.length();
        for (int i=0; i<len; i++) {
            if (s.charAt(i) == 'Q') {
                l.add(i);
            }
        }
        int qq = l.size();
        int q = (int)Math.sqrt(qq);
//        System.out.println("q: " + q + " " + q*q + " " + qq);
        if (q*q != qq) return false; 
        if (q == 0) return true;
        
        int hh = len - qq;
        int h = hh / (q+1); 
//        System.out.println("h: " + h + " " + (h+q*h) + " " + hh);
        if (h*(q+1) != hh) return false;
        
        Integer[] a = l.toArray(new Integer[0]);
        
        int prefix = a[0];
        int suffix = (len-1-a[qq-1]);
        if (prefix % 2 != 0 || suffix % 2 != 0) return false;
        prefix/=2;
        suffix/=2;
        
        for (int i=1; i<q; i++) {
            for (int j=1; j<q; j++) {
                if (a[i]-a[i-1] != a[j*q+i] - a[j*q+i-1]) return false;
            }
        }
        for (int i=1; i<q; i++) {
            if (a[i*q] - a[i*q-1] - prefix - suffix != a[i]-a[i-1]) return false;
        }
        
        return true;
    }
    
}