#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
#define pi 2*acos(0.0)
#define f first
#define s second
#define inf INT_MAX
#define MXN 500001
#define endl "\n"
#define eps 1e-6
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rev(x) x.rbegin(), x.rend()
#define spc(x) cout << fixed << setprecision(x)
#define fastio {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define test ll t; cin >> t; while (t--)
typedef long long ll;
using namespace std;
void solve()
{
ll n,k;
cin>>n>>k;
string s; cin>>s;
ll cnt=0;
vector<ll> v;
for(int i=0;i<s.size();i++){
if(s[i]=='1'){
cnt++;
}
else{
if(cnt>0){
v.pb(cnt);
}
cnt=0;
}
}
if(cnt>0){
v.pb(cnt);
}
k++;
ll left = 0;
ll right = 0;
ll mx=0;
ll sum=0;
while(right<v.size()){
sum+=v[right];
if(right-left+1>k){
sum-=v[left];
left++;
}
right++;
mx = max(mx,sum);
}
cout<<mx<<endl;
}
int32_t main()
{
fastio
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}