#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL);
  int q;
  cin >> q;
  while (q--) {
    long long n, k;
    cin >> n >> k;
    string a;
    cin >> a;
    long long f = n + 1;
    long long l = -1;
    long long prev = -1;
    long long ans = 0;
    long long ok = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] == '1') {
        f = min(f, i);
        l = max(l, i);
        if (prev >= 0) {
          long long c = 0;
          for (long long j = prev + k + 1; j + k + 1 <= i; j += (k + 1)) {
            c++;
          }
          long long d = 0;
          for (long long j = i - (k + 1); j >= prev + k + 1; j -= (k + 1)) {
            d++;
          }
          ans += max(d, c);
        }
        prev = i;
        ok = 1;
      }
    }
    if (!ok) {
      cout << max(1LL, (n) / (k + 1) + bool(n % (k + 1))) << "\n";
      continue;
    }
    if (f != n + 1)
      for (long long i = 0; i + k + 1 <= f; i += (k + 1)) {
        ans++;
      }
    if (l >= 0)
      for (long long i = l + k + 1; i < n; i += (k + 1)) {
        ans++;
      }
    cout << ans << "\n";
  }
}
