#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    int count = 0;
    char x;
    int lwb = 0;
    bool f = false;
    for (int i = 0; i < n; i++) {
      cin >> x;
      if (x == '1') {
        if (!f) {
          lwb = count;
        } else {
          ans += count / (k + 1);
          if (count / (k + 1) > 0 && count % (k + 1) != k) {
            ans--;
          }
        }
        count = 0;
        f = true;
      } else {
        count++;
      }
    }
    ans += lwb / (k + 1);
    ans += count / (k + 1);
    if (count == n && n % (k + 1) > 0) {
      ans++;
    }
    cout << ans << '\n';
  }
  return 0;
}
