#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, cnt = 0, c = 0, k, sum = 0;
    string ar;
    cin >> n >> k;
    cin >> ar;
    for (int i = 0; i < n; i++) {
      if (ar[i] == '1') sum++;
      if (ar[i] == '1' && i == 0) cnt++;
      if (ar[i] == '0' && (c == k || i == 0)) {
        ar[i] = '1';
        cnt++;
        c = 0;
      } else if (ar[i] == '1' && i > 0 && c < k)
        c = 0;
      else if (ar[i] == '1' && c == k) {
        c = 0;
        cnt++;
      }
      if (i > 0 && ar[i] == '0') {
        c++;
      }
    }
    cout << cnt - sum << endl;
  }
  return 0;
}
