시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB26421419580.247%

문제

Mike wrote some text on a piece of paper and now he wants to know how many holes are in the text.

What is a hole in this context?

If you think of the paper as the plane and a letter as a curve on the plane, then each letter divides the plane into regions. For example letters "A" and "O" divide the plane into two regions so we say these letters each have one hole. Similarly, letter "B" has two holes and letters such as "C", "E", "F" and "K" have no holes. Spaces, of course, have no holes.

We say that the number of holes in the text is equal to the total number of holes in the letters of the text. Help Mike to determine how many holes are in the text.

입력

Input starts with an integer, N, on a line of its own (0 < N <= 30). It tells you how many lines of text follow. There then follow N lines of text. Each line contains a string of text composed only of upper case letters and spaces; it will contain at least 1 letter. The length of the text is no more than 250 characters.

출력

For each line of input, output a single line containing the number of holes in the corresponding text.

예제 입력 1

3
CHEAT CODE
HAVE A CUP OF TEA
NEW ZEALAND

예제 출력 1

3
5
3