#include
#include
using namespace std;
int main(){
int t;
char string[99];
cin>>t;
while(t--){
cin>>string;
int l=strlen(string);
int count=0;
for(int i=0;i<l;i++){
char newString=string[i];
if(newString=='A'||newString=='D'||newString=='O'||newString=='P'||newString=='R')
count++;
else if(newString=='B')
count+=2;
}cout<<count<<endl;
}
return 0;
}
It works fine on my system . I am using DevCPP 5.8.3(TDM - GCC-4.8.1)