Problem Description


Besides skipping class, it is also important to meet other girls for luras in the new term.

As you see, luras sneaked into another girl's QQgroup to meet her indescribable aim.

However, luras can only speak like a cat. To hide her real identity, luras is very careful to each of her words.

She knows that many girls love saying "233",however she has already made her own word at first, so she needs to fix it.

Her words is a string of length n,and each character of the string is either '2' or '3'.

Luras has a very limited IQ which is only m.

She could swap two adjacent characters in each operation, which makes her losing 2 IQ.

Now the question is, how many substring "233"s can she make in the string while her IQ will not be lower than 0 after her operations?

for example, there is 1 "233" in "2333", there are 2 "233"s in "2332233", and there is no "233" in "232323".


 



Input


The first line is an integer T which indicates the case number.

and as for each case,

the first line are two integers n and m,which are the length of the string and the IQ of luras correspondingly.

the second line is a string which is the words luras wants to say.

It is guaranteed that——

1 <= T <= 1000

for 99% cases, 1 <= n <= 10, 0 <= m <= 20

for 100% cases, 1 <= n <= 100, 0<= m <= 100


 



Output


As for each case, you need to output a single line.

there should be one integer in the line which represents the largest possible number of "233" of the string after her swap.


 



Sample Input


3
6 2
233323
6 1
233323
7 4
2223333

 



Sample Output


2
1
2

动态规划,用dp[i][j][k]表示第i个2放在第j个位置的时候,交换了k次的最多的233个数

#include<map> 
#include<set>
#include<ctime>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
#define ms(x,y) memset(x,y,sizeof(x))
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define per(i,j,k) for(int i=j;i>=k;i--)
#define loop(i,j,k) for (int i=j;i!=-1;i=k[i])
#define inone(x) scanf("%d",&x)
#define intwo(x,y) scanf("%d%d",&x,&y)
#define inthr(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define infou(x,y,z,p) scanf("%d%d%d%d",&x,&y,&z,&p)
#define lson x<<1,l,mid
#define rson x<<1|1,mid+1,r
#define mp(i,j) make_pair(i,j)
#define ft first
#define sd second
typedef long long LL;
typedef pair<LL, LL> pii;
const int low(int x) { return x&-x; }
const int INF = 0x7FFFFFFF;
const int mod = 1e9 + 7;
const int N = 1e2 + 10;
const double eps = 1e-10;
int T, n, m, a[N], cnt, flag = 1;
int dp[N][N][N / 2], g[N][N][N / 2];
char s[N];

int main()
{
for (inone(T); T--; flag++)
{
intwo(n, m);
scanf("%s", s + 1); cnt = 0;
rep(i, 1, n) if (s[i] == '2') a[++cnt] = i;
int ans = 0;
rep(i, 1, cnt)
{
rep(j, i, n - cnt + i)
{
int q = abs(a[i] - j);
rep(k, q, m / 2)
{
dp[i][j][k] = 0;
if (i == 1) g[i][j][k] = flag;
rep(jj, i - 1, j - 1)
{
if (i == 1 || g[i - 1][jj][k - q] < flag) continue;
dp[i][j][k] = max(dp[i][j][k], dp[i - 1][jj][k - q] + (j - jj > 2));
g[i][j][k] = flag;
}
if (g[i][j][k] < flag) continue;
if (i == cnt && n - j > 1) dp[i][j][k]++;
if (i == cnt) ans = max(ans, dp[i][j][k]);
}
}
}
printf("%d\n", ans);
}
return 0;
}