#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int pre[N];
void solve() {
  string s;
  int n, k, ans = 0;
  cin >> n >> k >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      if (i == 0)
        pre[i] = 1;
      else
        pre[i] = pre[i - 1] + 1;
    } else {
      if (i == 0)
        pre[i] = 0;
      else
        pre[i] = pre[i - 1];
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      i += k;
      continue;
    }
    int l = i - k - 1;
    int r = i + k;
    l = max(0, l);
    r = min(r, n - 1);
    if (pre[l] == pre[r]) {
      ans++;
      i = r;
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int tc = 1;
  cin >> tc;
  while (tc--) {
    solve();
  }
  return 0;
}
