#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int maxConsecutiveOnes(string &s, int n, int k) {
int maxLen = 0;
int 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++;
}
maxLen = max(maxLen, right - left + 1);
}
return maxLen;
}
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
string s;
cin >> n >> k >> s;
cout << maxConsecutiveOnes(s, n, k) << endl;
}
return 0;
}