#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    string s, t;
    cin >> n >> k >> s;
    t = s;
    for (int i = 0; i < n; i++) {
      if (t[i] == '1') {
        for (int j = i; j <= i + k && j < n; j++) t[j] = '1';
        i = i + k;
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (s[i] == '1') {
        for (int j = i; j >= 0 && j >= i - k; j--) s[j] = '1';
        i = i - k;
      }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1' || t[i] == '1')
        s[i] = '1';
      else
        s[i] = '0';
    }
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        cnt++;
        for (int j = i; j <= i + k && j < n; j++) t[j] = '1';
        i = i + k;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
