#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int last = -1, ans = 0, ps;
    for (int i = 0; i < n; i++) {
      if (s[i] - '0' == 1) {
        if (last == -1) {
          ps = max(0, i - k);
        } else {
          ps = max(0, i - last - 1 - 2 * k);
        }
        if (ps > 0) {
          ans++;
          ps--;
          ans += ps / (k + 1);
        }
        last = i;
      }
    }
    if (last != -1) {
      ps = max(0, n - last - 1 - k);
      if (ps > 0) {
        ans++;
        ps--;
        ans += ps / (k + 1);
      }
    } else {
      ps = n;
      if (ps > 0) {
        ans++;
        ps--;
        ans += ps / (k + 1);
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
