#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e18;
const long long MAX = 100001;
void solve() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  long long j = -1;
  long long i = 0;
  long long count = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == '1') {
      long long zeros = i - j - 1;
      if (j == -1) {
        zeros -= k;
      } else {
        zeros -= (2 * k);
      }
      j = i;
      double res = (double)zeros / (k + 1);
      long long no = ceil(res);
      count += no;
    }
  }
  long long zeros = i - j - 1;
  if (j != -1) zeros -= k;
  double res = (double)zeros / (k + 1);
  long long no = ceil(res);
  count += no;
  cout << count << endl;
  return;
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
