UAP Programming Contest Club (UPCC)

Limits 1s, 1.0 GB

Asif loves UAP Programming Contest Club (UPCC). Wherever he goes looks for “UPCC”. One day he met a guy named Mr. Gates, Asif told Mr. Gates that he was tired of looking for “UPCC” manually everywhere and wants an automation system. But Mr. Gates was not a good programmer that’s why he came to you and told you to write a programme which will find out the number of time Asif can make “UPCC” from a Given String. You have to keep in mind that Asif is going to use every character only for once.
.

Input

The first line of the input contains an Integer T (≤ 100) denoting the number of test cases. Each of the next T line consist of a String X (1≤ X ≤ 1000)

Output

For each case print the number of time you can make “UPCC” from X.

Sample

InputOutput
3
ABCDEFGHIJKLMNOPQRSTUVCWXYZ
BPCCUPCCPU
BCUPUUPPPUUUUU
1
2
0

Sequence is not a matter. You just need to see whether the character U,P, C is available in the string or not.