#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
int sum() { return 0; }
template <typename T, typename... Args>
T sum(T a, Args... args) {
  return a + sum(args...);
}
int tt, n, k;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> tt;
  while (tt--) {
    string s;
    cin >> n >> k >> s;
    int l(0), r(0), one(0), free(0);
    for (int i = 0; i < n; ++i) {
      if (s[i] == '0') {
        if (l < k)
          l++;
        else if (r <= k)
          r++;
        if (l + r > k && (i - l - r + 1 == 0 || i == n - 1)) free++, r = 0;
        if (l + r == (2 * k + 1)) free++, l = r - 1, r = 0;
      } else {
        if (l + r < (2 * k + 1) && l > k && i - (l + r) == 0)
          free++;
        else if (l + r == (2 * k + 1))
          free++;
        l = 0;
        r = 0;
        one++;
      }
    }
    if (one == 0 && n >= 1 && free == 0) free++;
    cout << free << '\n';
  }
}
