#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int T, n, k, pre[N];
string s;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (cin >> T; T--;) {
    cin >> n >> k;
    cin >> s;
    memset(pre, 0, sizeof(pre));
    for (int i = 1; i <= n; i++) {
      pre[i] = (s[i - 1] == '1');
      if (i) pre[i] += pre[i - 1];
    }
    pre[0] = 0;
    pre[n + 1] = pre[n];
    int res = 0;
    for (int i = 1; i <= n; i++) {
      if (s[i - 1] == '0' && pre[max(0, i - 1)] - pre[max(0, i - k - 1)] == 0 &&
          pre[min(n, i + k)] - pre[min(n, i)] == 0) {
        res++, i += k;
      }
    }
    cout << res << endl;
  }
  return 0;
}
