#include <bits/stdc++.h>
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T cube(T x) {
  return x * x * x;
}
template <class T>
inline void Mini(T &x, T y) {
  x = max((x), (y));
}
template <class T>
inline void Maxi(T &x, T y) {
  x = min((x), (y));
}
using namespace std;
int prime(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
void InitPrime() {
  int pr[2000005];
  fill(pr + 1, pr + 1001, 1);
  pr[1] = 0;
  for (long long i = 2; i <= 1000; i++)
    if (pr[i])
      for (int j = i + i; j <= 1000; j += i) pr[j] = 0;
}
void AddMOD(int &x, int y) {
  x += y;
  if (x >= 10000000005) x -= 10000000005;
}
long long tinh(long long a, long long b, long long c) {
  if (b == 1) return a % c;
  long long x = tinh(a, b / 2, c);
  long long y = (1ll * x * x) % c;
  if (b % 2 != 0) y = (1ll * y * a) % c;
  return y;
}
const int base = 131;
const long long MM = 1ll * 10000000005 * 10000000005;
const int oo = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
long long t, m, n, k, dem, a[2000005], last = -1, dd[2000005];
string s;
void act() {
  cin >> n >> k;
  cin >> s;
  long long p = 1, ans = 0;
  k++;
  for (long long i = 0; i < n; i++) {
    p--;
    if (s[i] == '0' && p == 0) {
      p = k;
      ans++;
    }
    if (s[i] == '1' && p == 0) {
      p = k;
      continue;
    }
    if (s[i] == '1' && p != 0) {
      p = k;
      ans--;
    }
  }
  cout << ans << endl;
}
void act2() {
  long long n, k, dem = 0;
  cin >> n >> k;
  cin >> s;
  long long m = s.length();
  dd[0] = s[0] - 48;
  for (long long i = 1; i <= m - 1; i++) dd[i] = dd[i - 1] + (s[0] - 48);
  for (long long i = 0; i < m; i++) {
    if (s[i] == '0') {
      long long tm = dd[max(m - 1, i + k)] - dd[min((long long)0, i - k - 1)];
      if (tm == 0) {
        dem++;
        i = i + k;
      }
    } else
      continue;
  }
  cout << dem << endl;
}
int main() {
  cin >> t;
  while (t--) {
    act();
  }
}
