#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int min = n + 1, count = n + 1;
    for (int i = 0; i < n; ++i) {
      if (s[i] == '1') {
        if (count < min) min = count;
        count = 0;
      } else {
        count++;
      }
    }
    int pre[n], post[n], cnt = n, ans = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] == '1') {
        cnt = 0;
        pre[i] = -1;
      } else {
        cnt++;
        pre[i] = cnt;
      }
    }
    cnt = n;
    for (int i = n - 1; i >= 0; --i) {
      if (s[i] == '1') {
        cnt = 0;
        post[i] = -1;
      } else {
        cnt++;
        post[i] = cnt;
      }
    }
    for (int i = 0; i < n; ++i) {
      if (pre[i] > k && post[i] > k) {
        ans++;
        i += k;
      }
    }
    cout << ans << endl;
  }
}
