#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, counter = 0, ans = 0;
    bool firstonefounded = false;
    string s;
    cin >> n >> k;
    cin >> s;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        counter++;
      } else {
        if (firstonefounded) {
          counter -= 2 * k;
        } else {
          counter -= k;
        }
        if (counter > 0) {
          ans += ceil((double)counter / (k + 1));
        }
        firstonefounded = true;
        counter = 0;
      }
    }
    if (counter > 0) {
      if (firstonefounded) {
        counter -= k;
      }
      ans += ceil((double)counter / (k + 1));
    }
    cout << ans << '\n';
  }
  return 0;
}
