import java.util.Scanner;
import java.io.*;
class HOLES
{
// A B-2 D O P Q R
public static void main
(String args
[]) {
Scanner input
=new Scanner
(System.
in);int count,i,j,len,t;
//System.out.println("Enter the number of test cases");
try
{
t=input.nextInt();
while(t>0)
//for(i=1;i<=t;i++)
{
//System.out.println("enter the text");
count=0;
len=s.length();
if(len>=100)
len=99;
for(i=0;i<len;i++)
{
if((s.charAt(i)=='A') || (s.charAt(i)=='D') || (s.charAt(i)=='O') || (s.charAt(i)=='P') || (s.charAt(i)=='Q') || (s.charAt(i)=='R'))
{
count++;
}
else if(s.charAt(i)=='B')
{
count=count+2;
}
else
{
continue;
}
}
t--;
}
}
{
}
}
}
CmltcG9ydCBqYXZhLnV0aWwuU2Nhbm5lcjsKaW1wb3J0IGphdmEuaW8uKjsKY2xhc3MgSE9MRVMKewpzdGF0aWMgSW5wdXRTdHJlYW1SZWFkZXIgaXNyPW5ldyBJbnB1dFN0cmVhbVJlYWRlcihTeXN0ZW0uaW4pOwpzdGF0aWMgQnVmZmVyZWRSZWFkZXIgYnI9bmV3IEJ1ZmZlcmVkUmVhZGVyKGlzcik7Ci8vIEEgQi0yIEQgTyBQIFEgUiAKcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nIGFyZ3NbXSkKewpTY2FubmVyIGlucHV0PW5ldyBTY2FubmVyKFN5c3RlbS5pbik7CmludCBjb3VudCxpLGosbGVuLHQ7Ci8vU3lzdGVtLm91dC5wcmludGxuKCJFbnRlciB0aGUgbnVtYmVyIG9mIHRlc3QgY2FzZXMiKTsKdHJ5CnsKdD1pbnB1dC5uZXh0SW50KCk7CndoaWxlKHQ+MCkKLy9mb3IoaT0xO2k8PXQ7aSsrKQp7CgovL1N5c3RlbS5vdXQucHJpbnRsbigiZW50ZXIgdGhlIHRleHQiKTsKU3RyaW5nIHM9YnIucmVhZExpbmUoKTsKCmNvdW50PTA7Cmxlbj1zLmxlbmd0aCgpOwppZihsZW4+PTEwMCkKbGVuPTk5Owpmb3IoaT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