#include <bits/stdc++.h>
using namespace std;
void solve() {
int N, K;
string S;
cin >> N >> K >> S;
int maxConsecutiveOnes = 0, left = 0, zeroCount = 0;
for (int right = 0; right < N; ++right) {
if (S[right] == '0') zeroCount++;
// If too many zeros, shrink the window
while (zeroCount > K) {
if (S[left] == '0') zeroCount--;
left++;
}
// Maximum window with at most K zero flips
maxConsecutiveOnes = max(maxConsecutiveOnes, right - left + 1);
}
cout << maxConsecutiveOnes << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
solve();
}
return 0;
}