Subsequence of AB

Subsequence of AB

Time Limit: 1.0 s

Memory Limit: 128.0 MB

Description

You are given a string S and the length of the string is N. You need to perform at most K operations (Possibly zero) of the string S.
In each operation,
You can choose an index \(i\), \(1<= i<= N\), where \(S[i]\)=?, change its character by either A or B.(Ex. \(S[i] = A\) or \(S[i] = B\)).

After perfroming above operation on string S, find the occurrence of "AB" as the subsequence of final string S.

For example, Subsequence of string S=\(ABC\) -> {\(A,B,C,AB,AC,BC,ABC\)}.

You need to perform operation such way that, total occurrence of "AB" is as maximum as possible.

Input

First line T, the number of test cases.
In each test case, first line two positive integers N and K.
Second line, a string S, the length of string is N.

\(1<=T<=10000\)
\(1<= N <= 2 * 10^5\)
\(1<= K <= 10^9\)
String \(S\) contains english uppercase alphabets and \(?\) .
Sum of \(N\) overall test case doesn't exceed \(2 * 10^5\)

Output

In each test case, print the maximum occurrence of AB as the subsequence of final string S.

Sample

Input Output
2
6 2
AABC?B
3 3
?B?
6
2

Information

ID
1110
Difficulty
7
Category
(None)
Tags
(None)
# Submissions
54
Accepted
12
Accepted Ratio
22%
Uploaded By

Related

In following contests:

Brain Booster #7