#include <bits/stdc++.h>
int pmod(int n, int m) { return (n % m + m) % m; }
int next(int n, int m) { return n + pmod(-n, m); }
int main() {
  int t;
  std::cin >> t;
  while (t--) {
    int n, k;
    std::cin >> n >> k;
    std::string str;
    std::cin >> str;
    std::string oth(str.size(), '0');
    int c = 0;
    for (int ti = -k - 1; ti - k < n; ti++) {
      if (ti >= 0 && ti < n && c == 0) oth[ti] = 'x';
      if (ti + k + 1 < n) c += str[ti + k + 1] - '0';
      if (ti - k >= 0) c -= str[ti - k] - '0';
    }
    char prev = '0';
    int init = -1, end = -1;
    int sol = 0;
    for (int i = 0; i <= n; i++) {
      char curr;
      if (i == n)
        curr = '0';
      else
        curr = oth[i];
      if (curr == 'x' && prev != 'x') {
        init = i;
      }
      if (curr != 'x' && prev == 'x') {
        end = i;
        sol += next(end - init, k + 1) / (k + 1);
      }
      prev = curr;
    }
    std::cout << sol << "\n";
  }
}
