#include <stdio.h>
#include <string.h>
int maxConsecutiveOnes(char S[], int N, int K) {
int maxcount = 0, left = 0, zerocount = 0;
for (int right = 0; right < N; right++) {
if (S[right] == '0') {
zerocount++;
}
while (zerocount > K) {
if (S[left] == '0') {
zerocount--;
}
left++;
}
int windowsize = right - left + 1;
if (windowsize > maxcount) {
maxcount = windowsize;
}
}
return maxcount;
}
void solve() {
int N, K;
scanf("%d %d", &N, &K);
char S[N + 1];
scanf("%s", S);
printf("%d\n", maxConsecutiveOnes(S, N, K));
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
solve();
}
return 0;
}