Burger Stand

You have been planning for a long time to open a roadside burger stand, but you failed to find a sweet spot for the little shop. In Bangladesh, it is fairly common to open small shops right by the side of roads and footpaths, causing troubles to everyone else passing by the roads. On a bright side, many people stop by and buy stuffs from these shops on their way. So you thought, why you don’t do the same. But being a computer science student, you have little more civil sense (surprisingly) than most others. So, instead of opening the shops at will, you have decided to maintain the following conditions when choosing a spot for your burger stand.

  1. It is not directly in front of a private driveway. 2. It is not directly in front of a bus stop.
  2. It is not 5 meters before a bus stop.
  3. It is not 10 meters before a bus stop.
  4. It is not directly in front of a side-street. 6. It is not 5 meters before a side-street.
  5. It is not 5 meters after a side-street. A road segment will be represented as a String, where each character describes a section of the road 5 meters in length. So the first character describes the first 5 meters of the road, the second character describes the next 5 meters and so on. We will use ‘D’ for driveway, ‘B’ for bus stop, ‘S’ for side-street and ‘-’ for all other sections of the street. A position is directly in front of an object if it has the same index as the object in the road. A position is before an object if its index is lower than the index of the object in the road. Finally, a position is after an object if its index is higher than the index of the object in the road. Note, your shop only takes one position. Given the road segment calculate the total number of possible spaces for your burger stand on that road. Input First line will contain an integer T (1 ≤ T ≤ 50), the number of test cases. Each of the following T lines will contain a string S denoting a road segment as described above. There will be at most 50 characters in any line. Output For each case produce a line of output ‘Case X: Y ’, where X is the test case number starting from 1 and Y is the number of possible spaces for your burger stand. Check sample input and output for details. Explanation: For the first case, you can open the burger stand in position 1, 5, 10 and 14. On the second case, there is empty spot.

2/2 Sample Input 2 ---B--S-D--S-- DDBDDBDDBDD Sample Output Case 1: 4 Case 2: 0