#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  };
  long long t, n, k;
  string str;
  cin >> t;
  while (t--) {
    long long cnt = 0, l = -1, r = -1, now;
    cin >> n >> k >> str;
    for (int i = 0; i < (int)str.size(); i++) {
      if (str[i] == '1' or i == (int)str.size() - 1) {
        if (str[i] == '1') r = i;
        if (l == -1 and r != -1)
          now = r - k;
        else if (l == -1 and r == -1)
          now = (int)str.size();
        else if (l != -1 and r == -1)
          now = (int)str.size() - l - k - 1;
        else
          now = r - l - 1 - 2 * k;
        now = max(now, 0ll);
        if (now) cnt += now / (k + 1) + (now - now / (k + 1) * (k + 1) >= 1);
        l = r;
        r = -1;
      }
    }
    cout << cnt << '\n';
  }
  return 0;
}
