#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int prev = -(k + 1);
    int ans = 0;
    for (int i = 0; i < (int)s.length(); i++) {
      if (s[i] == '1') {
        int d = i - prev;
        ans += d / (k + 1) - 1;
        prev = i;
      }
    }
    int last = n - 1 + (k + 1);
    int d = last - prev;
    ans += d / (k + 1) - 1;
    cout << ans << endl;
  }
  return 0;
}
