#include <bits/stdc++.h>
using namespace std;
const int sz = 1e5 + 9, inf = INT_MAX;
void solve() {
  int n, m, k, l, r, x, y, ans = 0, a, b;
  cin >> n >> k;
  string s;
  cin >> s;
  int pre[n];
  memset(pre, -1, sizeof(pre));
  ;
  if (s[0] == '1') {
    pre[0] = 0;
  }
  for (int i = 1; i < n; i++) {
    pre[i] = pre[i - 1];
    if (s[i] == '1') {
      pre[i]++;
    }
  }
  for (int i = 0; i < n;) {
    if (s[i] == '1') {
      if (i + k + 1 < n && pre[i + k + 1] == pre[i] && i + k + 1 + k < n &&
          pre[i + k + 1] == pre[i + k + 1 + k]) {
        ans++;
        s[i + k + 1] = '1';
        i = i + k + 1 + k + 1;
        continue;
      } else if (i + k + 1 >= n) {
        break;
      }
      if (pre[i + k + 1] == pre[i]) {
        i = i + k + 1;
        continue;
      }
      for (int j = i + 1; j < n; j++) {
        if (s[j] == '1') {
          i = j;
          break;
        }
      }
      continue;
    }
    if (s[i] == '0') {
      if (i + k < n && pre[i + k] == pre[i]) {
        ans++;
        s[i] = '1';
        i = i + k + 1;
        continue;
      } else if (i + k >= n && pre[i] == pre[n - 1]) {
        ans++;
        break;
      } else if (i + k >= n && pre[i] != pre[n - 1]) {
      }
      for (int j = i + 1; j < n; j++) {
        if (s[j] == '1') {
          i = j;
          break;
        }
      }
      continue;
    }
  }
  cout << ans << "\n";
  ;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  cin >> t;
  while (t--) solve();
}
