408311: GYM103091 K Marbles

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. Marblestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are trying to solve a puzzle posed by some Stanford students.

You have a line of marbles, with some white and some black. You can only remove marbles from either end of the line. What is the greatest number of white marbles you can remove, given that you are only allowed to remove at most $$$K$$$ black marbles? You can assume there are at least $$$K+1$$$ black marbles in the line.

Input

The first line of the input contains 2 space separated integers $$$N$$$, ($$$1\leq N \leq 10^6$$$) and $$$K$$$, ($$$1 \leq K < N$$$). $$$N$$$ is the total number of marbles, and $$$K$$$ is the maximum number of black marbles you're able to remove. The second line of input is a string of length $$$N$$$, with the characters 'W' for white marbles and 'B' for black marbles.

Output

Output a single integer representing the greatest number of white marbles you can remove.

ExamplesInput
10 3
WWWBBBBWWW
Output
6
Input
15 3
WWBBBWWWWWBBBBB
Output
7

加入题单

算法标签: