#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
using namespace std;
int cnt[N];
int val(int win, int k) {
  int ans = win / (k + 1);
  if (win % (k + 1) != 0) ++ans;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> pos, win;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') pos.push_back(i + 1);
    }
    int l = pos.size();
    int ans = 0;
    if (l == 0) {
      cout << val(n, k) << endl;
      continue;
    }
    win.push_back(max(0, pos[0] - 1 - k));
    win.push_back(max(0, n - pos[l - 1] - k));
    for (int i = 1; i < l; i++) {
      int mid = pos[i] - pos[i - 1] - 2 * k - 1;
      win.push_back(max(0, mid));
    }
    for (auto i : win) {
      ans += val(i, k);
    }
    cout << ans << endl;
  }
}
