#include <bits/stdc++.h>
using namespace std;
long long int pow1(long long int n, long long int p) {
  if (p == 0) return 1;
  long long int x = pow1(n, p / 2);
  x = (x * x) % 1000000007;
  if (p % 2 == 0) return x;
  return (x * n) % 1000000007;
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  long long int ans = 0;
  if (s[0] == '0') ans++;
  long long int temp = 0;
  for (long long int i = 1; i < n; i++) {
    if (s[i] == '0') {
      if (temp == k) {
        temp = 0;
        ans++;
      } else
        temp++;
    } else {
      if (temp < k) {
        ans--;
      }
      temp = 0;
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
