#include <bits/stdc++.h>
using namespace std;
long long int fpow(long long int n, long long int k,
                   long long int p = 1000000007) {
  long long int r = 1;
  n = n % p;
  while (k > 0) {
    if (k & 1) {
      r = (r * n) % p;
    }
    k = k >> 1;
    n = (n * n) % p;
  }
  return r;
}
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i += 6) {
    if (n % i == 0 || n % (i + 2) == 0) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int tc;
  cin >> tc;
  while (tc--) {
    long long int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    long long int l = -1, r;
    vector<long long int> v;
    for (long long int i = 0; i < n; i++) {
      if (s[i] == '1') {
        v.push_back(i);
        if (l == -1) l = i;
        r = i;
      }
    }
    long long int ans = 0;
    if (l == -1) {
      for (long long int i = 0; i < n; i += (k + 1)) {
        if (s[i] == '0') ans++;
      }
      cout << ans;
    } else {
      for (long long int i = 0; i < v.size() - 1; i++) {
        long long int d = v[i + 1] - v[i];
        if (d >= (k + 1) * 2) {
          long long int q = d / (k + 1);
          if (q > 0) q--;
          ans += q;
        }
      }
      long long int p = l;
      while (p >= 0) {
        if (s[p] == '0') ans++;
        p -= (k + 1);
      }
      p = r;
      while (p < n) {
        if (s[p] == '0') ans++;
        p += (k + 1);
      }
      cout << ans;
    }
    cout << "\n";
  }
  return 0;
}
