#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, k;
  cin >> t;
  string s;
  while (t--) {
    set<long long> s1;
    cin >> n >> k;
    cin >> s;
    long long c = 0;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '1') s1.insert(i);
    }
    s1.insert(-k - 1);
    s1.insert(n + k);
    auto i = s1.begin(), j = s1.begin();
    advance(j, 1);
    long long x = *i;
    for (long long it = 0; it <= n - 1; it++) {
      if (it - x >= k + 1 && s[it] == '0' && (*j) - it >= k + 1) {
        x = it;
        c++;
      }
      if (it == (*j)) {
        x = *j;
        j++;
      }
    }
    cout << c << "\n";
  }
  return 0;
}
