eolymp
bolt
Try our new interface for solving problems
Problems

Parking

Parking

You want to park the car guests who have come to the party, on the street. According to the rules the cars cannot park: \begin{itemize} \item In front of the private exit; \item At the bus stop and less than $10$ meters before it; \item At the pedestrian crossing, and less than $5$ meters before it or after it. \end{itemize} You made plans for the surrounding streets, smashing them into sections the length of $5$ meters (this is the minimum length for parking). Land with exit on the plane is denoted by $'D'$, bus stops --- $'B'$, crossings --- $'S'$, others --- $'-'$. Write a program that for each street will determine the number of parking spaces. \InputFile The first line contains the number of streets $n~(1 \le n \le 100)$. It is followed by $n$ lines containing street maps, each line has a length from $1$ to $50$ characters long and consists only of characters $'D', 'B', 'S'$ and $'-'$. \OutputFile For each street plan, print the number of parking spaces. \includegraphics{https://static.eolymp.com/content/d5/d5d4461e7a7bd689d558a93a4006763eae5ac747.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
3
---B--S-D--S--
DDBDDBDDBDD
--S--S--S--S--
Output example #1
4
0
2