#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long i, j, k, n, c = 0, mx, ans = 0;
    cin >> n >> k;
    string s;
    cin >> s;
    mx = k;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '1') {
        if (mx < k) ans--;
        mx = 0;
      } else {
        mx++;
        if (mx == k + 1) {
          ans++;
          mx = 0;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
