Bob and Bombs

3.9

77 votes
Approved, Basic Programming, Easy, Implementation, Open
Problem

Bob and Khatu are brave soldiers in World War 3. They have spotted an enemy troop which is planting bombs. They sent message to the command centre containing characters W and B where W represents a wall and B represents a Bomb. They asked command to tell them how many walls will be destroyed if all bombs explode at once. One bomb can destroy 2 walls on both sides.

Input:

First line of input contains number of test cases T. Each test case contains a single string which contains two type of chars 'W' and 'B'.

Output:

For each test case print the total number of destroyed wall.

Constraints:

1 ≤ T ≤ 10
1 ≤ |S| ≤ 105

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?