#include <stdio.h>
int maxConsecutiveOnes(int N, int K, const char* S) {
int left = 0, right = 0, max_len = 0, count_zeros = 0;
while (right < N) {
if (S[right] == '0') {
count_zeros++;
}
while (count_zeros > K) {
if (S[left] == '0') {
count_zeros--;
}
left++;
}
max_len = (right - left + 1) > max_len ? (right - left + 1) : max_len;
right++;
}
return max_len;
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
int N, K;
scanf("%d %d", &N, &K);
char S[N + 1];
scanf("%s", S);
int result = maxConsecutiveOnes(N, K, S);
printf("%d\n", result);
}
return 0;
}