Problem2335--Black and White Stripe

2335: Black and White Stripe

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

You have a stripe of checkered paper of length nn. Each cell is either white or black.

What is the minimum number of cells that must be recolored from white to black in order to have a segment of kk consecutive black cells on the stripe?

If the input data is such that a segment of kk consecutive black cells already exists, then print 0.

Input

The first line contains an integer tt (1≤t≤1041≤t≤104) — the number of test cases.

Next, descriptions of tt test cases follow.

The first line of the input contains two integers nn and kk (1≤k≤n≤2⋅1051≤k≤n≤2⋅105). The second line consists of the letters 'W' (white) and 'B' (black). The line length is nn.

It is guaranteed that the sum of values nn does not exceed 2⋅1052⋅105.

Output

For each of tt test cases print an integer — the minimum number of cells that need to be repainted from white to black in order to have a segment of kk consecutive black cells.

Sample Input Copy

4
5 3
BBWBW
5 5
BBWBW
5 1
BBWBW
1 1
W

Sample Output Copy

1
2
0
1

Source/Category