#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int t, n, k;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> k;
    cin >> s;
    int l = k + 1, ans = 0, r = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '1')
        l = 0;
      else
        l++;
      if (l > k && s[i] == '0') s[i] = '2', l = 0;
    }
    l = 1000000;
    for (int i = s.size() - 1; i >= 0; i--) {
      if (s[i] == '2') {
        if (l - i > k) ans++;
        l = i;
      } else if (s[i] == '1')
        l = i;
    }
    cout << ans << '\n';
  }
}
