#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s = string(k + 1, '0') + s + string(k + 1, '0');
    s.front() = '1';
    s.back() = '1';
    n = s.length();
    int res = 0, l = 0;
    for (int i = 0, r = 0; i < n; i++) {
      while (r <= i or s[r] == '0') r++;
      if (s[i] == '1') {
        l = i;
      } else {
        if ((i - l) > k and (r - i) > k) {
          s[i] = '1';
          res++;
          l = i;
        }
      }
    }
    cout << res << '\n';
  }
}
