#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long N = 1e5 + 10;
const long double Pie = acos(-1);
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    long long ans = 0;
    set<long long> st;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '1') st.insert(i);
    }
    for (long long i = 0; i < n; i++) {
      if (s[i] == '0') {
        auto it = st.lower_bound(i - k);
        if (it == st.end() or *it > i + k) {
          ans++;
          s[i] = '1';
          st.insert(i);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
