#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '1') {
      for (int j = max(0, i - k); j <= (min(i + k, n - 1)); j++) {
        if (s[j] == '0') s[j] = 'w';
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      ans++;
      for (int j = max(0, i - k); j <= (min(i + k, n - 1)); j++) {
        if (s[j] == '0') s[j] = 'w';
      }
    }
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
