#include <bits/stdc++.h>
using namespace std;
unordered_set<int> int_set;
set<int, greater<int> > divisors;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    int n, k;
    long long i;
    string a;
    cin >> n >> k >> a;
    long long ans = 0, cnt;
    int m = a.length();
    for (i = 0; i < n; i++) {
      if (a[i] == '1') break;
    }
    long long temp = ((i + k) / (k + 1));
    if (i == n)
      ans += temp;
    else
      ans += (i / (k + 1));
    cnt = 0;
    i++;
    for (long long j = i; j < m; j++) {
      long long temp = ((cnt - k) / (k + 1));
      if (a[j] == '1') {
        ans += temp;
        cnt = 0;
      } else
        cnt++;
    }
    k++;
    int rem = (cnt / k);
    ans += rem;
    cout << ans << "\n";
  }
  return 0;
}
