Mandy is a working artist and is commissioned to create some art pieces for 2018. The client wants Mandy to create art pieces out of cardboard boxes to display at the local art show. Occasionally, Mandy plans to drive by the local store on her way home to grab some boxes for her art pieces.
Mandy's cat, Willow, likes to play with every box that Mandy brings home. Willow plays with a box for days before getting bored of it. Once Willow is bored with a box, she never returns to it again, meaning that Mandy can finally use the empty box in her art projects.
If Mandy brings home another box before Willow finishes playing with the previous one, Willow will wait until she is bored with the previous box before moving onto the new one.
Given Mandy's box-shopping habits over the next days, can you determine by how many days the project will be delayed due to Willow?
Input Specification
The standard input will contain 10 datasets.
Each dataset begins with two integers and . The next lines each contain either the letter E
or B
which represent whether Mandy came home empty-handed or with a box that day.
Output Specification
For each dataset, output the number of days that Willow will be playing with the boxes after the days given in the dataset.
Sample Input
3 5
E
B
E
B
E
2 4
B
E
E
E
Sample Output
2
0
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments
Any insight on the last test case in datasets 2 and 3. I have 28/30 correct, but can't get the last test case in those two datasets to go.