#include <bits/stdc++.h>
using namespace std;
long long fx[4] = {1, -1, 0, 0};
long long fy[4] = {0, 0, 1, -1};
long long ox8[] = {0, 0, 1, 1, 1, -1, -1, -1};
long long oy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return a.first > b.first;
}
long long pw(long long a, long long b) {
  long long ans = 1;
  for (long long i = 1; i <= b; ++i) ans = (ans * a);
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<long long> a;
    long long o = 0;
    bool prtm = false;
    if (s[0] == '0') prtm = true;
    bool last = false;
    if (s[n - 1] == '0') last = true;
    for (int i = 0; i < n; i++) {
      char x = s[i];
      if (x == '1') {
        if (o) a.push_back(o);
        o = 0;
      } else
        o++;
    }
    if (o) a.push_back(o);
    long long cr_h = 0;
    if (a.size() == 1 && last && prtm) {
      long long ans = (a[0] - 1) / (k + 1);
      cout << ans + 1 << "\n";
      continue;
    }
    long long j = 0;
    for (auto i : a) {
      ++j;
      if (j == 1 && prtm) {
        cr_h += (i / (k + 1));
        continue;
      }
      if (j == a.size() && last) {
        cr_h += (i / (k + 1));
        continue;
      }
      if (i <= 2 * k) continue;
      long long rem = i % (k + 1);
      cr_h += (i / (k + 1));
      if (rem != k) cr_h--;
    }
    cout << cr_h << "\n";
  }
  return 0;
}
