#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, k, idx = 0, ans = 0;
    scanf("%d%d", &n, &k);
    string s;
    cin >> s;
    if (s[0] == '0') ans++;
    for (int i = 1; i < n; ++i) {
      if (s[i] == '0' && (i - idx) > k) {
        ans++;
        idx = i;
      } else if (s[i] == '1') {
        if (i - idx <= k) ans--;
        idx = i;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
