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

"There is a trick:if the cat has played all the previous boxes,the expected deadline should minus 1"

Not sure what you mean by that, but there are no negative days. I fully solved the problem and one of my earlier errors that I found and fixed was that I was computing (potentially) negative days past the N given days. You can't have that.

came back after 2 weeks and got it now....last two test cases have a point in the middle of the data set where Willow finishes playing with the current boxes before getting more boxes.

I'm also having trouble with the last dataset of the 2nd and 3rd test case. Something must be wrong with my math, but I don't know what the last dataset is testing? Can anyone help?

what is different in the last test case? I keep failing on it.

Edit: Nvm I figured it out with some help

There is a trick:if the cat has played all the previous boxes,the expected deadline should minus 1