#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<long long> l_r, r_l;
  long long count = k + 1;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '1') {
      count = 0;
      l_r.push_back(0);
    } else if (s[i] == '0') {
      count++;
      if (count > k)
        l_r.push_back(1);
      else
        l_r.push_back(0);
    }
  }
  count = k + 1;
  for (long long i = n - 1; i >= 0; i--) {
    if (s[i] == '1') {
      count = 0;
      r_l.push_back(0);
    } else if (s[i] == '0') {
      count++;
      if (count > k)
        r_l.push_back(1);
      else
        r_l.push_back(0);
    }
  }
  reverse(r_l.begin(), r_l.end());
  long long i = 0, ans = 0;
  while (i < n) {
    if (l_r[i] && r_l[i]) {
      ans++;
      i += k;
    }
    i++;
  }
  cout << ans << "\n";
  return;
}
int main() {
  long long t;
  cin >> t;
  for (long long i = 0; i < t; i++) solve();
  return 0;
}
