#include <bits/stdc++.h>
using namespace std;
int main() {
  int xx = 0;
  int t;
  cin >> t;
  while (t--) {
    long long n, k, i;
    string s;
    cin >> n >> k >> s;
    long long num = 0, d = k;
    for (i = 0; i < n; i++) {
      if (s[i] == '1') {
        if (d < k) num--;
        d = 0;
      }
      if (s[i] == '0') {
        d++;
        if (d == k + 1) {
          d = 0;
          num++;
        }
      }
    }
    cout << num;
    cout << "\n";
  }
  return 0;
}
