#include <bits/stdc++.h>
using namespace std;
long long int answer(long long int n, long long int k) {
  if (n % (k + 1) == 0)
    return n / (k + 1);
  else
    return n / (k + 1) + 1;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    string str;
    cin >> str;
    bool flag[n];
    memset(flag, false, sizeof(flag));
    long long int o = 0, first = 0;
    for (long long int i = 0; i < n; i++) {
      if (str[i] == '1') {
        flag[i] = true;
        long long int temp = k;
        while (temp) {
          if (i + temp < n) flag[i + temp] = true;
          if (i - temp >= 0) flag[i - temp] = true;
          temp--;
        }
      }
    }
    long long int count = 0, ans = 0;
    for (long long int i = 0; i < n; i++) {
      if (!flag[i])
        count++;
      else {
        if (count > 0) {
          ans += answer(count, k);
          count = 0;
        }
      }
    }
    if (count > 0) {
      ans += answer(count, k);
      count = 0;
    }
    cout << ans << "\n";
  }
  return 0;
}
