ECOO '18 R1 P1 - Willow's Wild Ride

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 30.0s
Memory limit: 64M

Author:
Problem type

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 T 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 N 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 T (2 \le T \le 7) and N (1 \le N \le 365). The next N 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 N 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

There are no comments at the moment.