#include <bits/stdc++.h>
using namespace std;
int precheck(vector<char> v, vector<int> &ind, int n, int k) {
  int size = ind.size(), ans = 0;
  for (int i = 0; i < size - 1; i++) {
    if ((ind[i + 1] - ind[i] - 1) < k) return 0;
  }
  if (size == 0) {
    for (int i = 0; i < n; i = i + k + 1) {
      ans++;
    }
    return ans;
  }
  int start = 0;
  int end = ind[0];
  end -= k;
  for (int i = start; i < end; i += k + 1) ans++;
  start = ind[size - 1];
  if (start < (n - 1)) {
    start = ind[size - 1] + k + 1;
    for (int i = start; i < n; i += k + 1) ans++;
  }
  for (int i = 0; i < size - 1; i++) {
    start = ind[i] + k + 1;
    end = ind[i + 1] - k;
    for (int i = start; i < end; i += k + 1) ans++;
  }
  return ans;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    char c;
    vector<char> v;
    vector<int> ind;
    for (int i = 0; i < n; i++) {
      cin >> c;
      v.push_back(c);
      if (v[i] == '1') ind.push_back(i);
    }
    cout << precheck(v, ind, n, k) << endl;
  }
  return 0;
}
