#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
char str[maxn];
int sum[maxn];
int n, k;
inline int lowbit(int x) { return -x & x; }
void add(int x, int y) {
  while (x <= n) {
    sum[x] += y;
    x += lowbit(x);
  }
}
int ask(int x) {
  int res = 0;
  while (x) {
    res += sum[x];
    x -= lowbit(x);
  }
  return res;
}
void solve() {
  scanf("%d%d", &n, &k);
  getchar();
  scanf("%s", str + 1);
  for (int i = 1; i <= n; ++i) {
    sum[i] = 0;
  }
  for (int i = 1; i <= n; ++i) {
    if (str[i] == '1') add(i, 1);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int l = max(1, i - k), r = min(i + k, n);
    if (str[i] == '0' && ask(r) == ask(l - 1)) {
      ++ans;
      str[i] = '1';
      add(i, 1);
    }
  }
  cout << ans << '\n';
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
