#include <bits/stdc++.h>
using namespace std;
int func(string &a, int k) {
  int n = a.size();
  int count = 0, total = 0;
  if (a[0] == '0') {
    count = k + 1;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] == '0') {
      count++;
    } else {
      count = 0;
    }
    if (count == 2 * k + 1) {
      total++;
      count = k;
    }
  }
  if (a[n - 1] == '0' && count > k) total++;
  return total;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string a;
    cin >> a;
    int ans = 0;
    ans = max(ans, func(a, k));
    reverse(a.begin(), a.end());
    ans = max(ans, func(a, k));
    cout << ans << endl;
  }
}
