#include <bits/stdc++.h>
using namespace std;
int cnt, ans;
int k, n;
bool issafe(string &s, int &i) {
  int l, r;
  if (i - k <= 0)
    l = 0;
  else
    l = i - k;
  if (i + k > n - 1)
    r = s.length() - 1;
  else
    r = i + k;
  while (l <= r) {
    if (s[l] == '1') {
      i = l;
      return false;
    }
    l++;
  }
  s[i] = '1';
  return true;
}
int main() {
  cin >> cnt;
  while (cnt--) {
    cin >> n >> k;
    string s;
    ans = 0;
    cin.ignore();
    getline(cin, s);
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') {
        i += k;
        continue;
      }
      if (issafe(s, i)) {
        ans++;
      }
      if (s[i] == '1') {
        i += k;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
