CodeChef Problem 6 - Holes in the text

this solution is for the problem for finding the number of holes in the file
for characters 'A', 'D', 'O', 'P', 'Q', 'R' the number of holes is 1 and for 'B' is 2
the first line of input contains the number of test cases followed by the words in the 
capital letter.