// from #650
// https://codeforces.com/contest/1367/problem/C
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            e.tbls.push_back (j);
        }
    }
    return e;
}
v ib, ie;
v how_many (v &ib, v &ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2 + 1;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
void result (name &e) {
    if (e.tbls.size() == 0) {
        if (e.size <= e.dist) {
            e.count = 1;
        }
        else {
            double siz = e.size, d = e.dist,
            tmp = siz / (d + 1);
            e.count += ceil (tmp);
        }
    }
    else if (e.tbls.size() == 1) {
        e.count += e.tbls[0] / (e.dist + 1);
        e.count += (e.size - e.tbls[0] - 1) / (e.dist + 1);
    }
    else {
        e.count += e.tbls[0] / (e.dist + 1);
        v n = e.tbls.size();
        for (v j = 0; j < n - 1; j++) {
            e.count += how_many (e.tbls[j], e.tbls[j + 1], e.dist);
        }
        e.count += (e.size - e.tbls.back() - 1) / (e.dist + 1);
    }
    cout << e.count << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        result (e);
    }
    return 0;
}


// from #650
// https://codeforces.com/contest/1367/problem/C
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            e.tbls.push_back (j);
        }
    }
    return e;
}
v how_many (v ib, v ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2 + 1;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
void result (name &e) {
    if (e.tbls.size() == 0) {
        if (e.size <= e.dist) {
            e.count = 1;
        }
        else {
            double siz = e.size, d = e.dist,
            tmp = siz / (d + 1);
            e.count += ceil (tmp);
        }
    }
    else if (e.tbls.size() == 1) {
        e.count += e.tbls[0] / (e.dist + 1);
        e.count += (e.size - e.tbls[0] - 1) / (e.dist + 1);
    }
    else {
        e.count += e.tbls[0] / (e.dist + 1);
        v n = e.tbls.size();
        for (v j = 0; j < n - 1; j++) {
            e.count += how_many (e.tbls[j], e.tbls[j + 1], e.dist);
        }
        e.count += (e.size - e.tbls[n - 1] - 1) / (e.dist + 1);
    }
    cout << e.count << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        result (e);
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
v how_many (v ib, v ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
int main () {
    v n, c = 0, ib, ie;
    bool open = false;
    string tmp;
    cin >> n;
    name e[n];
    for (v i = 0; i < n; i++) {
        cin >> e[i].size >> e[i].dist;
        e[i].count = 0;
        cin >> tmp;
        for (v j = 0; j < e[i].size; j++) {
            if (tmp[j] == '1') {
                e[i].tbls.push_back(j);
            }
        }
    }
    for (v i = 0; i < n; i++) {
        if (e[i].tbls.size() == 0) {
            ib = 0;
            ie = e[i].size - 1;
            e[i].count += how_many (ib, ie, e[i].dist) + 1;

        }
        else if (e[i].tbls.size() == 1) {
            e[i].count += how_many (-1, e[i].tbls[0], e[i].dist);
            e[i].count += how_many (e[i].tbls[0], e[i].size - 1, e[i].dist);
        }
        else {
            for (v j = 0; j < e[i].tbls.size(); j += 2) {
                ib = e[i].tbls[j];
                ie = e[i].tbls[j + 1];
                e[i].count += how_many (ib, ie, e[i].dist);
            }
        }
    }
    for (v i = 0; i < n; i++) {
        cout << e[i].count << endl;
    }
    return 0;
}


// from #650
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            e.tbls.push_back (j);
        }
    }
    return e;
}
v how_many (v ib, v &ie, v &dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
void result (name &e) {
    if (e.tbls.size() == 0) {
        if (e.size <= e.dist) {
            e.count = 1;
        }
        else {
            e.count += e.size / (e.dist + 1);
        }
    }
    else if (e.tbls.size() == 1) {
        e.count += e.tbls[0] / (e.dist + 1);
        e.count += (e.size - e.tbls[0] - 1) / (e.dist + 1);
    }
    else {
        for (v j = 0; j < e.tbls.size(); j++) {
            e.count += how_many (e.tbls[j], e.tbls[j + 1], e.dist);
        }
    }
    cout << e.count << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        cout << '\n';
        result (e);
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
v how_many (v ib, v ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
int main () {
    v n, c = 0, ib, ie;
    bool open = false;
    string tmp;
    cin >> n;
    name e[n];
    for (v i = 0; i < n; i++) {
        cin >> e[i].size >> e[i].dist;
        e[i].count = 0;
        cin >> tmp;
        for (v j = 0; j < e[i].size; j++) {
            if (tmp[j] == '1') {
                if (open == false) {
                    open = true;
                }
                else { // if open == true
                    open = false;
                }
                if (c != 0) {
                    e[i].tbls.push_back(c);
                    c = 0;
                }
            }
            else {
                c++;
            }
        }
        if (c != 0) {
            e[i].tbls.push_back(c);
        }
        c = 0;
    }
    for (v i = 0; i < n; i++) {
        for (v j = 0; j < e[i].tbls.size(); j++) {
            if (e[i].tbls.size() == 1) {
                e[i].count += e[i].tbls[0] / (e[i].dist + 1);
                if (e[i].tbls[0] <= e[i].dist) {
                    e[i].count += 1;
                }
            }
            else {
                e[i].count += ((e[i].tbls[j] + 1) / (e[i].dist + 1)) - 1;
            }
        }
    }
    for (v i = 0; i < n; i++) {
        cout << e[i].count << endl;
    }
    return 0;
}


// from #650
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            e.tbls.push_back (j);
        }
    }
    return e;
}
v how_many (v ib, v ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
void result (name &e) {
    if (e.tbls.size() == 0) {
        if (e.size <= e.dist) {
            e.count = 1;
        }
        else {
            e.count += e.size / (e.dist + 1);
        }
    }
    else if (e.tbls.size() == 1) {
        e.count += e.tbls[0] / (e.dist + 1);
        e.count += (e.size - e.tbls[0] - 1) / (e.dist + 1);
    }
    else {
        for (v j = 0; j < e.tbls.size() - 1; j++) {
            e.count += how_many (e.tbls[j], e.tbls[j + 1], e.dist);
        }
    }
    cout << e.count << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        result (e);
    }
    return 0;
}


// from #650
// https://codeforces.com/contest/1367/problem/C
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            e.tbls.push_back (j);
        }
    }
    return e;
}
v how_many (v ib, v ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2 + 1;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
double tmp, siz, d;
void result (name &e) {
    if (e.tbls.size() == 0) {
        if (e.size <= e.dist) {
            e.count = 1;
        }
        else {
            double siz = e.size, d = e.dist,
            tmp = siz / (d + 1);
            e.count += ceil (tmp);
        }
    }
    else if (e.tbls.size() == 1) {
        e.count += e.tbls[0] / (e.dist + 1);
        e.count += (e.size - e.tbls[0] - 1) / (e.dist + 1);
    }
    else {
        for (v j = 0; j < e.tbls.size() - 1; j++) {
            e.count += how_many (e.tbls[j], e.tbls[j + 1], e.dist);
        }
    }
    cout << e.count << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        result (e);
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            if (open == false) {
                open = true;
            }
            else { // if open == true
                open = false;
            }
            if (c != 0) {
                e.tbls.push_back(c);
                c = 0;
            }
        }
        else {
            c++;
        }
    }
    if (c != 0) {
        e.tbls.push_back(c);
    }
    c = 0;
    return e;
}
void result (name &e) {
    if (e.tbls.size() == 1) {
        if (e.tbls[0] <= e.dist) {
            e.count += 1;
        }
        else {
            e.count += e.tbls[0] / (e.dist + 1);
        }
    }
    else {
        for (v j = 0; j < e.tbls.size(); j++) {
            e.count += ((e.tbls[j] + 1) / (e.dist + 1)) - 1;
        }
    }
    cout << e.count << endl;
}
int main () {
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        result (e);
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
v how_many (v ib, v ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
int main () {
    v n, c = 0, ib, ie;
    bool open = false;
    string tmp;
    cin >> n;
    name e[n];
    for (v i = 0; i < n; i++) {
        cin >> e[i].size >> e[i].dist;
        e[i].count = 0;
        cin >> tmp;
        for (v j = 0; j < e[i].size; j++) {
            if (tmp[j] == '1') {
                e[i].tbls.push_back(j);
            }
        }
    }
    cout << endl;
    for (v i = 0; i < n; i++) {
        if (e[i].tbls.size() == 0) {
            ib = 0;
            ie = e[i].size - 1;
            e[i].count += how_many (ib, ie, e[i].dist) + 1;

        }
        else if (e[i].tbls.size() == 1) {
            e[i].count += how_many (-1, e[i].tbls[0], e[i].dist);
            e[i].count += how_many (e[i].tbls[0], e[i].size - 1, e[i].dist);
        }
        else {
            for (v j = 0; j < e[i].tbls.size(); j += 2) {
                ib = e[i].tbls[j];
                ie = e[i].tbls[j + 1];
                e[i].count += how_many (ib, ie, e[i].dist);
            }
        }
    }
    cout << endl;
    for (v i = 0; i < n; i++) {
        cout << e[i].count << endl;
    }
    /* v c = 0;
    v ib = 0, ie = 15, dist = 1;
    while (ib < ie) {
        ib += dist * 2;
        if (ib < ie) {
            c++;
        }
    }
    cout << c << endl;
    */
    return 0;
}


// from #650
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            e.tbls.push_back (j);
        }
    }
    return e;
}
v how_many (v ib, v ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
void result (name &e) {
    if (e.tbls.size() == 0) {
        if (e.size <= e.dist) {
            e.count = 1;
        }
        else {
            e.count += e.size / (e.dist + 1);
        }
    }
    else if (e.tbls.size() == 1) {
        e.count += e.tbls[0] / (e.dist + 1);
        e.count += (e.size - e.tbls[0] - 1) / (e.dist + 1);
    }
    else {
        for (v j = 0; j < e.tbls.size() - 1; j++) {
            e.count += how_many (e.tbls[j], e.tbls[j + 1], e.dist);
        }
    }
    cout << e.count << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        cout << '\n';
        result (e);
    }
    return 0;
}


// from #650
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            e.tbls.push_back (j);
        }
    }
    return e;
}
v how_many (v ib, v ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
double tmp, siz, d;
void result (name &e) {
    if (e.tbls.size() == 0) {
        if (e.size <= e.dist) {
            e.count = 1;
        }
        else {
            double siz = e.size, d = e.dist,
            tmp = siz / (d + 1);
            e.count += ceil (tmp);
        }
    }
    else if (e.tbls.size() == 1) {
        e.count += e.tbls[0] / (e.dist + 1);
        e.count += (e.size - e.tbls[0] - 1) / (e.dist + 1);
    }
    else {
        for (v j = 0; j < e.tbls.size() - 1; j++) {
            e.count += how_many (e.tbls[j], e.tbls[j + 1], e.dist);
        }
    }
    cout << e.count << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        result (e);
    }
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
#define v long long
#define loop(i, n) for (v i = 0; i < n; i++)
v lower_limit (vector <v> a, v key) {
    v l = 0, r = a.size() - 1, m;
    while (r > l + 1) {
        m = (l + r) / 2;
        if (a[m] < key)
            l = m;
        else
            r = m;
    }
    return l;
}
v higher_limit (vector <v> a, v key) {
    v l = 0, r = a.size() - 1, m;
    while (r > l + 1) {
        m = (l + r) / 2;
        if (a[m] > key)
            r = m;
        else
            l = m;
    }
    return r;
}
void print (vector <v> a) {
    loop (i, a.size()) {
        cout << a[i] << ' ';
    }
    cout << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v t;
    cin >> t;
    loop (i, t) {
        v size, dist, count = 0;
        string s;
        vector <v> c;
        cin >> size >> dist >> s;
        c.push_back (-dist - 1);
        //cout << endl;
        loop (j, s.size()) {
            if (s[j] == '1') {
                c.push_back (j);
            }
        }
        //cout << endl;
        c.push_back (size + dist);
        loop (j, s.size()) {
            if (s[j] == '0') {
                v l = lower_limit (c, j), h = higher_limit (c, j);
                //cout << "j = " << j << ' ' << c[l] << ' ' << c[h] << endl;
                if (c[l] <= j - dist - 1 && c[h] >= j + dist + 1) {
                    c.insert (c.begin() + l + 1, j);
                    //print (c);
                    count ++;
                }
            }
        }
        cout << count << '\n';
    }
    return 0;
}


// from #650
// https://codeforces.com/contest/1367/problem/C
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            e.tbls.push_back (j);
        }
    }
    return e;
}
v how_many (v ib, v &ie, v dist) {
    v c = 0;
    while (ib < ie) {
        if (c > 0) {
            ib += dist + 1;
        }
        else {
            ib += dist * 2 + 1;
        }
        //cout << ib << ' ' << ie << endl;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
void result (name &e) {
    if (e.tbls.size() == 0) {
        if (e.size <= e.dist) {
            e.count = 1;
            //cout << "first f " << e.count << ' ';
        }
        else {
            double siz = e.size, d = e.dist,
            tmp = siz / (d + 1);
            e.count += ceil (tmp);
            //cout << "first s " << e.count << ' ';
        }
    }
    else if (e.tbls.size() == 1) {
        e.count += e.tbls[0] / (e.dist + 1);
        //cout << "second " << e.count << ' ';
        e.count += (e.size - e.tbls[0] - 1) / (e.dist + 1);
    }
    else {
        e.count += e.tbls[0] / (e.dist + 1);
        v n = e.tbls.size();
        //cout << "third " << e.count << endl;
        for (v j = 0; j < n - 1; j++) {
            e.count += how_many (e.tbls[j], e.tbls[j + 1], e.dist);
            //cout << e.count << '\n';
        }
        e.count += (e.size - e.tbls.back() - 1) / (e.dist + 1);
    }
    cout << e.count << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        result (e);
    }
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
#define v short
#define loop(i, n) for (v i = 0; i < n; i++)
v lower_limit (vector <v> a, v key) {
    v l = 0, r = a.size() - 1, m;
    while (r > l + 1) {
        m = (l + r) / 2;
        if (a[m] < key)
            l = m;
        else
            r = m;
    }
    return l;
}
v higher_limit (vector <v> a, v key) {
    v l = 0, r = a.size() - 1, m;
    while (r > l + 1) {
        m = (l + r) / 2;
        if (a[m] > key)
            r = m;
        else
            l = m;
    }
    return r;
}
void print (vector <v> a) {
    loop (i, a.size()) {
        cout << a[i] << ' ';
    }
    cout << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v t;
    cin >> t;
    loop (i, t) {
        v size, dist, count = 0;
        string s;
        vector <v> c;
        cin >> size >> dist >> s;
        c.push_back (-dist - 1);
        //cout << endl;
        loop (j, s.size()) {
            if (s[j] == '1') {
                c.push_back (j);
            }
        }
        //cout << endl;
        c.push_back (size + dist);
        loop (j, s.size()) {
            if (s[j] == '0') {
                v l = lower_limit (c, j), h = higher_limit (c, j);
                //cout << "j = " << j << ' ' << c[l] << ' ' << c[h] << endl;
                if (c[l] <= j - dist - 1 && c[h] >= j + dist + 1) {
                    c.insert (c.begin() + l + 1, j);
                    //print (c);
                    count ++;
                }
            }
        }
        cout << count << '\n';
    }
    return 0;
}


#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

#define MOD 1000000007
#define rep(i, a, n) for(ll i = a ; i < m ; i++)
#define pb(a) push_back(a)

int main()
{
	int t = 1;
	cin >> t;
	while(t--)
	{
		ll n = 0, m = 0, k = 0, x = 0;
		cin >> n >> k;

		string str;
		cin >> str;

		int ans = 0;

		int i = str.find('1', 0);

		if(i == string::npos)
		{
			ans = (n - 1) / (k + 1) + 1;
		}

		else
		{
			int j = str.find('1', i + 1);

			if(j == string::npos)
			{
				ans = (i - k + 1 > 0 ? ((i - k + 1) / (k + 1)) : 0) + (n - i > 0 ? ((n - i - 1) / (k + 1)) : 0);
			}

			while(j != string::npos)
			{

				ans += (j - i - 1 - k) / (k + 1);
				i = j;
				j = str.find('1', j + 1);
			}
		}

		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

#define MOD 1000000007
#define rep(i, a, n) for(ll i = a ; i < m ; i++)
#define pb(a) push_back(a)

int main()
{
	int t = 1;
	cin >> t;
	while(t--)
	{
		ll n = 0, m = 0, k = 0, x = 0;
		cin >> n >> k;

		string str;
		cin >> str;

		int ans = 0;

		int i = str.find('1', 0);

		if(i == string::npos)
		{
			ans = (n - 1) / (k + 1) + 1;
		}

		else
		{
			int j = str.find('1', i + 1);

			if(j == string::npos)
			{
				ans = (i / (k + 1)) + ((n - 1 - i) / (k + 1)) ;
			}

			else
			{
				ans += i / (k + 1);
				while(j != string::npos)
				{
					ans += (j - i) / (k + 1) - 1;
					i = j;
					j = str.find('1', j + 1);
				}
				ans += (n - i - 1) / (k + 1);
			}
		}

		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

#define MOD 1000000007
#define rep(i, a, n) for(ll i = a ; i < m ; i++)
#define pb(a) push_back(a)

int main()
{
	int t = 1;
	cin >> t;
	while(t--)
	{
		ll n = 0, m = 0, k = 0, x = 0;
		cin >> n >> k;

		string str;
		cin >> str;

		int ans = 0;

		int i = str.find('1', 0);

		if(i == string::npos)
		{
			ans = (n - 1) / (k + 1) + 1;
		}

		else
		{
			int j = str.find('1', i + 1);

			if(j == string::npos)
			{
				ans = i / (k + 1) + (n - 1 - i ) / (k + 1) ;
			}

			while(j != string::npos)
			{

				ans += (j - i - 1 - k) / (k + 1);
				i = j;
				j = str.find('1', j + 1);
			}
		}

		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

#define MOD 1000000007
#define rep(i, a, n) for(ll i = a ; i < m ; i++)
#define pb(a) push_back(a)

int main()
{
	int t = 1;
	cin >> t;
	while(t--)
	{
		ll n = 0, m = 0, k = 0, x = 0;
		cin >> n >> k;

		string str;
		cin >> str;

		int ans = 0;

		int i = str.find('1', 0);

		if(i == string::npos)
		{
			ans = (n + 1) / (k + 1);
		}

		else
		{
			int j = str.find('1', i + 1);

			if(j == string::npos)
			{
				ans = (i - k + 1 > 0 ? ((i - k + 1) / (k + 1)) : 0) + (n - i > 0 ? ((n - i - 1) / (k + 1)) : 0);
			}

			while(j != string::npos)
			{

				ans += (j - i - 1 - k) / (k + 1);
				i = j;
				j = str.find('1', j + 1);
			}
		}

		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

#define MOD 1000000007
#define rep(i, a, n) for(ll i = a ; i < m ; i++)
#define pb(a) push_back(a)

int main()
{
	int t = 1;
	cin >> t;
	while(t--)
	{
		ll n = 0, m = 0, k = 0, x = 0;
		cin >> n >> k;

		string str;
		cin >> str;

		int ans = 0;

		int i = str.find('1', 0);

		if(i == string::npos)
		{
			ans = (n + 1) / (k + 1);
		}

		else
		{
			int j = str.find('1', i + 1);

			if(j == string::npos)
			{
				ans = (i - k + 1 > 0 ? ((i - k + 1) / (k + 1)) : 0) + (n - i > 0 ? ((n - i) / (k + 1)) : 0);
			}

			while(j != string::npos)
			{

				ans += (j - i - 1 - k) / (k + 1);
				i = j;
				j = str.find('1', j + 1);
			}
		}

		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

#define MOD 1000000007
#define rep(i, a, n) for(ll i = a ; i < m ; i++)
#define pb(a) push_back(a)

int main()
{
	int t = 1;
	cin >> t;
	while(t--)
	{
		ll n = 0, m = 0, k = 0, x = 0;
		cin >> n >> k;

		string str;
		cin >> str;

		int ans = 0;

		int i = str.find('1', 0);

		if(i == string::npos)
		{
			ans = (n - 1) / (k + 1) + 1;
		}

		else
		{
			int j = str.find('1', i + 1);

			if(j == string::npos)
			{
				ans = (i / (k + 1)) + ((n - 1 - i) / (k + 1)) ;
			}

			while(j != string::npos)
			{

				ans += (j - i - 1 - k) / (k + 1);
				i = j;
				j = str.find('1', j + 1);
			}
		}

		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

#define MOD 1000000007
#define rep(i, a, n) for(ll i = a ; i < m ; i++)
#define pb(a) push_back(a)

int main()
{
	int t = 1;
	cin >> t;
	while(t--)
	{
		ll n = 0, m = 0, k = 0, x = 0;
		cin >> n >> k;

		string str;
		cin >> str;

		int ans = 0;

		int i = str.find('1', 0);

		if(i == string::npos)
		{
			ans = (n - 1) / (k + 1) + 1;
		}

		else
		{
			int j = str.find('1', i + 1);

			if(j == string::npos)
			{
				ans = (i / (k + 1)) + ((n - 1 - i) / (k + 1)) ;
			}

			else
			{
				while(j != string::npos)
				{
					ans += (j - i) / (k + 1) - 1;
					i = j;
					j = str.find('1', j + 1);
				}
				ans += (n - i - 1) / (k + 1);
			}
		}

		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define Endl cout<<"\n";
#define FastRead ios_base::sync_with_stdio(false);cin.tie(false),cout.tie(false)
using namespace std;
int main()
{
    FastRead;
    ll n,t,p,a,b;
    cin>>t;
    while(t--)
    {
        ll k,m=0,i,j,c=0,ans=0;
        string s;
        vector< ll >v;
        cin>>n>>k;
        cin>>s;
        for(i=0; i<n; i++)
        {
            if(s[i]=='0')
                c++;
            else
            {
                if(c>0)
                    v.push_back(c);
                c=0;
            }
        }
        if(c>0)
            v.push_back(c);
        if(v.size()==0)
        {
            cout<<0<<endl;
            continue;
        }
        else if(v.size()==1)
        {
            if(s[0]=='0' || s[n-1]=='0')
            {
                if(v[0]>=(k+1)){
                    ans+=((v[0]-1)/(k+1));
                    ans++;
                }
            }
            else
                ans+=((v[0]-k)/(k+1));
            if(v[0]==n && ans==0)ans=1;
            cout<<ans<<endl;
            continue;
        }
        else
        {
            if(s[0]=='0')
            {
                if(v[0]>=(k+1)){
                    ans+=((v[0]-1)/(k+1));
                    ans++;
                }
                m=1;
            }
            for(i=m; i<v.size()-1; i++)
            {
                ans+=(v[i]-k)/(k+1);
            }
            if(s[s.size()-1]=='0')
            {
                if((v[v.size()-1])>=(k+1)){
                    ans+=((v[v.size()-1]-1)/(k+1))+1;
                    ans++;
                }
            }
            else
                ans+=((v[v.size()-1]-k)/(k+1));
            cout<<ans<<endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define FastRead ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0)
using namespace std;
int main()
{
    ll t,n,m,i,j;
    string a;
    cin>>t;
    while(t--)
    {
        ll c=0,ans=0,k=0,f=0;
        cin>>n>>m>>a;
        c=m;
        for(i=0; i<n; i++)
        {
            if(a[i]=='0')c++;
            if(a[i]=='1'){
                c=0;
                f++;
                k=0;
            }
            if(c==m && k==1){
                ans++;
                k=0;
            }
            else if(c==m+1){
                k=1;
                c=0;
            }
        }
        if(k>0)ans++;
        if(f==0 && ans==0)ans++;
        cout<<ans<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define Endl cout<<"\n";
#define FastRead ios_base::sync_with_stdio(false);cin.tie(false),cout.tie(false)
using namespace std;
int main()
{
    FastRead;
    ll n,t,p,a,b;
    cin>>t;
    while(t--)
    {
        ll k,m=0,i,j,c=0,ans=0;
        string s;
        vector< ll >v;
        cin>>n>>k;
        cin>>s;
        for(i=0; i<n; i++)
        {
            if(s[i]=='0')
                c++;
            else
            {
                if(c>0)
                    v.push_back(c);
                c=0;
            }
        }
        if(c>0)
            v.push_back(c);
        if(v.size()==0)
        {
            cout<<0<<endl;
            continue;
        }
        else if(v.size()==1)
        {
            if(s[0]=='0' || s[n-1]=='0')
            {
                ans+=(v[0]/(k+1))+1;
            }
            else
                ans+=(v[0]-k/(k+1));
            if(v[0]==n && ans==0)ans=1;
            cout<<ans<<endl;
            continue;
        }
        else
        {
            if(s[0]=='0')
            {
                ans+=(v[0]/(k+1))+1;
                m=1;
            }
            for(i=m; i<v.size()-1; i++)
            {
                ans+=(v[i]-k)/(k+1);
            }
            if(s[s.size()-1]=='0')
            {
                ans+=(v[v.size()-1]/(k+1))+1;
            }
            else
                ans+=((v[v.size()-1]-k)/(k+1));
            cout<<ans<<endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define Endl cout<<"\n";
#define FastRead ios_base::sync_with_stdio(false);cin.tie(false),cout.tie(false)
using namespace std;
int main()
{
    FastRead;
    ll n,t,p,a,b;
    cin>>t;
    while(t--)
    {
        ll k,m=0,i,j,c=0,ans=0;
        string s;
        vector< ll >v;
        cin>>n>>k;
        cin>>s;
        for(i=0; i<n; i++)
        {
            if(s[i]=='0')
                c++;
            else
            {
                if(c>0)
                    v.push_back(c);
                c=0;
            }
        }
        if(c>0)
            v.push_back(c);
        if(v.size()==0)
        {
            cout<<0<<endl;
            continue;
        }
        else if(v.size()==1)
        {
            if(s[0]=='0' || s[n-1]=='0')
            {
                if(v[0]>=(k+1)){
                    ans+=((v[0]-1)/(k+1));
                    ans++;
                }
            }
            else
                ans+=(v[0]-k/(k+1));
            if(v[0]==n && ans==0)ans=1;
            cout<<ans<<endl;
            continue;
        }
        else
        {
            if(s[0]=='0')
            {
                if(v[0]>=(k+1)){
                    ans+=((v[0]-1)/(k+1));
                    ans++;
                }
                m=1;
            }
            for(i=m; i<v.size()-1; i++)
            {
                ans+=(v[i]-k)/(k+1);
            }
            if(s[s.size()-1]=='0')
            {
                if((v[v.size()-1])>=(k+1)){
                    ans+=((v[v.size()-1]-1)/(k+1))+1;
                    ans++;
                }
            }
            else
                ans+=((v[v.size()-1]-k)/(k+1));
            cout<<ans<<endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define Endl cout<<"\n";
#define FastRead ios_base::sync_with_stdio(false);cin.tie(false),cout.tie(false)
using namespace std;
int main()
{
    FastRead;
    ll n,t,p,a,b;
    cin>>t;
    while(t--)
    {
        ll k,m=0,i,j,c=0,ans=0;
        string s;
        vector< ll >v;
        cin>>n>>k;
        cin>>s;
        for(i=0; i<n; i++)
        {
            if(s[i]=='0')
                c++;
            else
            {
                if(c>0)
                    v.push_back(c);
                c=0;
            }
        }
        if(c>0)
            v.push_back(c);
        if(v.size()==0)
        {
            cout<<0<<endl;
            continue;
        }
        else if(v.size()==1)
        {
            if(s[0]=='0' || s[n-1]=='0')
            {
                if(v[0]-1>=(k+1))
                    ans+=((v[0]-1)/(k+1));
                    ans++;
            }
            else
                ans+=(v[0]-k/(k+1));
            if(v[0]==n && ans==0)ans=1;
            cout<<ans<<endl;
            continue;
        }
        else
        {
            if(s[0]=='0')
            {
                if(v[0]-1>=(k+1)){
                    ans+=((v[0]-1)/(k+1));
                    ans++;
                }
                m=1;
            }
            for(i=m; i<v.size()-1; i++)
            {
                ans+=(v[i]-k)/(k+1);
            }
            if(s[s.size()-1]=='0')
            {
                if((v[v.size()-1]-1)>=(k+1)){
                    ans+=((v[v.size()-1]-1)/(k+1))+1;
                    ans++;
                }
            }
            else
                ans+=((v[v.size()-1]-k)/(k+1));
            cout<<ans<<endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define Endl cout<<"\n";
#define FastRead ios_base::sync_with_stdio(false);cin.tie(false),cout.tie(false)
using namespace std;
int main()
{
    FastRead;
    ll n,t,p,a,b;
    cin>>t;
    while(t--)
    {
        ll k,m=0,i,j,c=0,ans=0;
        string s;
        vector< ll >v;
        cin>>n>>k;
        cin>>s;
        for(i=0; i<n; i++)
        {
            if(s[i]=='0')
                c++;
            else
            {
                if(c>0)
                    v.push_back(c);
                c=0;
            }
        }
        if(c>0)
            v.push_back(c);
        if(v.size()==0)
        {
            cout<<0<<endl;
            continue;
        }
        else if(v.size()==1)
        {
            if(s[0]=='0' || s[n-1]=='0')
            {
                if(v[0]-1>=(k+1)){
                    ans+=((v[0]-1)/(k+1));
                    ans++;
                }
            }
            else
                ans+=(v[0]-k/(k+1));
            if(v[0]==n && ans==0)ans=1;
            cout<<ans<<endl;
            continue;
        }
        else
        {
            if(s[0]=='0')
            {
                if(v[0]-1>=(k+1)){
                    ans+=((v[0]-1)/(k+1));
                    ans++;
                }
                m=1;
            }
            for(i=m; i<v.size()-1; i++)
            {
                ans+=(v[i]-k)/(k+1);
            }
            if(s[s.size()-1]=='0')
            {
                if((v[v.size()-1]-1)>=(k+1)){
                    ans+=((v[v.size()-1]-1)/(k+1))+1;
                    ans++;
                }
            }
            else
                ans+=((v[v.size()-1]-k)/(k+1));
            cout<<ans<<endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define Endl cout<<"\n";
#define FastRead ios_base::sync_with_stdio(false);cin.tie(false),cout.tie(false)
using namespace std;
int main()
{
    FastRead;
    ll n,t,p,a,b;
    cin>>t;
    while(t--)
    {
        ll k,m=0,i,j,c=0,ans=0;
        string s;
        vector< ll >v;
        cin>>n>>k;
        cin>>s;
        for(i=0; i<n; i++)
        {
            if(s[i]=='0')
                c++;
            else
            {
                if(c>0)
                    v.push_back(c);
                c=0;
            }
        }
        if(c>0)
            v.push_back(c);
        if(v.size()==0)
        {
            cout<<0<<endl;
            continue;
        }
        else if(v.size()==1)
        {
            if(s[0]=='0' || s[n-1]=='0')
            {
                ans+=(v[0]/(k+1));
            }
            else
                ans+=(v[0]-k/(k+1));
            if(v[0]==n && ans==0)ans=1;
            cout<<ans<<endl;
            continue;
        }
        else
        {
            if(s[0]=='0')
            {
                ans+=(v[0]/(k+1));
                m=1;
            }
            for(i=m; i<v.size()-1; i++)
            {
                ans+=(v[i]-k)/(k+1);
            }
            if(s[s.size()-1]=='0')
            {
                ans+=(v[v.size()-1]/(k+1));
            }
            else
                ans+=((v[v.size()-1]-k)/(k+1));
            cout<<ans<<endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define FastRead ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0)
using namespace std;
ll dp[1000006];
int main()
{
    FastRead;
    ll n,t,p,a,b;
    string s;
    cin>>t;
    while(t--)
    {
        ll k,m=0,i,j,c=0,ans=0,dis;
        vector< ll >v;
        cin>>n>>k>>s;
        for(i=0; i<n; i++)
        {
            if(s[i]=='0')
                c++;
            else
            {
                if(c>0)
                    v.push_back(c);
                c=0;
            }
        }
        if(c>0)
            v.push_back(c);
        if(v.size()==0)
        {
            cout<<0<<endl;
        }
        else if(v.size()==1)
        {
            if(s[0]=='0' || s[n-1]=='0')
            {
                ans+=(v[0]/(k+1));
            }
            else
                ans+=(v[0]-k/(k+1));
            if(v[0]==n && ans==0)ans=1;
        }
        else
        {
            if(s[0]=='0')
            {
                ans+=(v[0]/(k+1));
                m=1;
            }
            for(i=m; i<v.size()-1; i++)
            {
                ans+=(v[i]-k)/(k+1);
            }
            if(s[s.size()-1]=='0')
            {
                ans+=(v[v.size()-1]/(k+1));
            }
            else
                ans+=((v[v.size()-1]-k)/(k+1));
        }
        cout<<ans<<endl;
    }

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t;
	cin >> t;

	while(t--){
		long long n, k;
		string s;
		cin >> n >> k >> s;

		long long ans = 0;
		for(long long x=0;x<n;){
			long long i = x+1;
			for(;i<n && s[i] != '1';i++);

			long long left = (s[x] == '1' ? k : 0), right = (i<n && s[i] == '1' ? k : 0), length = i-x;

			if(left==k){
				length--;
			}

			length -= left+right;

			if(length > 0){
				ans += (length + k)/(k+1);
			}

			x = i;
			cout << "last i: " << i << "\n";
		}

		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t, n, k;
	cin >> t;

	while(t--){
		cin >> n >> k;

		char data[n];
		int firstIndex = -1;
		for(int x=0;x<n;x++){
			cin >> data[x];
			if(firstIndex == -1 && data[x] == '1') firstIndex = x;
		}

		int ans = 0;

		if(firstIndex == -1) firstIndex = 0;
		for(int x=0;x < n; x+=1+k){
			if(firstIndex + x < n && data[firstIndex+x] == '0'){
				ans++;
				data[firstIndex+x] == '1';
			}
			if(x != 0 && firstIndex-x >= 0 && data[firstIndex-x] == '0'){
				ans++;
				data[firstIndex-x] == '1';
			}
		}
		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t;
	cin >> t;

	while(t--){
		long long n, k, debt = 0, ans = 0;
		cin >> n >> k;

		vector<char> data;
		for(long long x=0;x<n;x++){
			char tmp;
			cin >> tmp;

			if(tmp == '1'){
				if(x > 0 && data.size() > 0){
					data.erase(max(data.begin(), data.end() - k), data.end());
				}
				debt += k;
			} else {
				if(debt == 0){
					data.push_back('0');
				} else {
					debt--;
				}
			}
		}

		for(long long x=0;x<data.size();x+=k+1){
			ans++;
		}
		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t;
	cin >> t;

	while(t--){
		long long n, k, debt = 0, ans = 0;
		cin >> n >> k;

		long long data = 0;
		for(long long x=0;x<n;x++){
			char tmp;
			cin >> tmp;

			if(tmp == '1'){
				data = max((long long) 0, data - k);
				debt += k;
			} else {
				if(debt == 0){
					data++;
				} else {
					debt--;
				}
			}
		}

		for(long long x=1;x<=data;x+=k+1){
			ans++;
		}
		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t;
	cin >> t;

	while(t--){
		long long n, k, debt = 0, ans = 0;
		cin >> n >> k;

		long long data = 0;
		for(long long x=0;x<n;x++){
			char tmp;
			cin >> tmp;

			if(tmp == '1'){
				if(data > 0){
					data = max((long long) 0, data - k);
				}
				debt += k;
			} else {
				if(debt == 0){
					data++;
				} else {
					debt--;
				}
			}
		}

		for(long long x=1;x<=data;x+=k+1){
			ans++;
		}
		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t;
	cin >> t;

	while(t--){
		long long n, k;
		string s;
		cin >> n >> k >> s;

		long long ans = 0;
		for(long long x=0;x<n;){
			long long i = x+1;
			for(;i<n && s[i] != '1';i++);

			long long left = (s[x] == '1' ? k : 0), right = (i<n && s[i] == '1' ? k : 0), length = i-x;

			if(left==k){
				length--;
			}

			length -= left+right;

			if(length > 0){
				ans += (length + k)/(k+1);
			}

			x = i;
			//cout << "last i: " << i << "\n";
		}

		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t;
	cin >> t;

	while(t--){
		int n, k, debt = 0, ans = 0;
		cin >> n >> k;

		vector<char> data;
		for(long long x=0;x<n;x++){
			char tmp;
			cin >> tmp;

			if(tmp == '1'){
				if(x > 0 && data.size() > 0){
					data.erase(max(data.begin(), data.end() - k), data.end());
				}
				debt += k;
			} else {
				if(debt == 0){
					data.push_back('0');
				} else {
					debt--;
				}
			}
		}

		for(int x=0;x<data.size();x+=k+1){
			ans++;
		}
		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t;
	cin >> t;

	while(t--){
		long long n, k, debt = 0, ans = 0;
		cin >> n >> k;

		long long data = 0;
		for(long long x=0;x<n;x++){
			char tmp;
			cin >> tmp;

			if(tmp == '1'){
				if(x > 0 && data > 0){
					data = max((long long) 0, data - k);
				}
				debt += k;
			} else {
				if(debt == 0){
					data++;
				} else {
					debt--;
				}
			}
		}

		for(long long x=0;x<data;x+=k+1){
			ans++;
		}
		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t, n, k;
	cin >> t;

	while(t--){
		cin >> n >> k;

		char data[n];
		int firstIndex = -1;
		for(int x=0;x<n;x++){
			cin >> data[x];
			if(firstIndex == -1 && data[x] == '1') firstIndex = x;
		}

		int ans = 0;

		if(firstIndex == -1) firstIndex = 0;
		for(int x=0;x < n; x+=1+k){
			if(firstIndex + x < n && data[firstIndex+x] == '0'){
				ans++;
				data[firstIndex+x] = '1';
			}
			if(firstIndex-x >= 0 && data[firstIndex-x] == '0'){
				ans++;
				data[firstIndex-x] = '1';
			}
		}
		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t;
	cin >> t;

	while(t--){
		long long n, k, firstIndex = -1;
		cin >> n >> k;

		char data[n];
		for(long long x=0;x<n;x++){
			cin >> data[x];
			if(firstIndex == -1 && data[x] == '1') firstIndex = x;
		}

		long long ans = 0;

		if(firstIndex == -1) firstIndex = 0;
		for(long long x=0;x < n; x+=1+k){
			if(firstIndex + x < n && data[firstIndex+x] == '0'){
				ans++;
				data[firstIndex+x] = '1';
			}
			if(firstIndex-x >= 0 && data[firstIndex-x] == '0'){
				ans++;
				data[firstIndex-x] = '1';
			}
		}
		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t;
	cin >> t;

	while(t--){
		long long n, k, firstIndex = -1;
		cin >> n >> k;

		char data[n];
		for(long long x=0;x<n;x++){
			cin >> data[x];
			if(firstIndex == -1 && data[x] == '1') firstIndex = x;
		}

		long long ans = 0;

		if(firstIndex == -1) firstIndex = 0;
		for(long long x=0;x<n;x++){
			if(data[x] == '0'){
				bool safe = true;
				for(int i=1;i<=k;i++){
					if((x+i < n && data[x+i] == '1') || (x-1 >= 0 && data[x-i] == '1')){
						safe = false;
						break;
					}
				}
				if(safe){
					ans++;
					data[x] = '1';
				}
			}
		}
		cout << ans << "\n";
	}

    return 0;
}


#include <iostream>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int t, n, k;
	cin >> t;

	while(t--){
		cin >> n >> k;

		char data[n];
		for(int x=0;x<n;x++){
			cin >> data[x];
		}

		int ans = 0;
		for(int x=0;x<n;x += 1+k){
			if(data[x] == '0'){
				bool safe = true;
				for(int i=x+1;i<=x+k && i<n;i++){
					if(data[i] == '1'){
						safe = false;
						break;
					}
				}
				if(safe) ans++;
			}
		}

		cout << ans << "\n";
	}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;

ll gcd(ll a, ll b){
	if (a == 0) return b;
	gcd(b  %a, a);
}

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

int main() {
    fast;
    int test;
    cin >> test;
    while(test--){
    	ll ans = 0;
    	ll n,k;
    	int flag = 0;
    	cin >> n >> k;
    	string str;
    	cin >> str;
    	vector<ll> arr;
    	for(ll i=0;i<n;++i){
    		if(str[i] == '1'){
    			arr.push_back(i);
    			flag = 1;
    		}
    	}
    	if(!flag){
    		for(int i=0;i<n;i+=k+1){
    			++ans;
    		}
    		cout<<ans<<"\n";
    		continue;
    	}
    	if(arr[0]>=2*k){
    			ans+=arr[0]/2*k;
    	}
    	for(int i=1;i<arr.size();++i){
    		ll dist = arr[i] - 1 - arr[i-1];
    		//cout<<dist;
    		if(dist>2*k){
    			ans+=dist/2*k;
    		}
    	}
    	cout<<ans<<"\n";
    }

}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;

ll gcd(ll a, ll b){
	if (a == 0) return b;
	gcd(b  %a, a);
}

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

int main() {
    fast;
    int test;
    cin >> test;
    while(test--){
    	ll ans = 0;
    	ll n,k;
    	int flag = 0;
    	cin >> n >> k;
    	string str;
    	cin >> str;
    	vector<ll> arr;
    	for(ll i=0;i<n;++i){
    		if(str[i] == '1'){
    			arr.push_back(i);
    			flag = 1;
    		}
    	}
    	if(!flag){
    		for(int i=0;i<n;i+=k+1){
    			++ans;
    		}
    		cout<<ans<<"\n";
    		continue;
    	}
    	for(int i=0;i<arr.size();++i){
    		if(arr[0]!=0 && arr[0]>k){
	    		ll dist = arr[0]-k;
	    		if(dist%(k+1)){
	    			ans+=dist/(k+1) + 1;
	    		}
	    		else{
	    			ans+=dist/(k+1);
	    		}
	    		continue;
	    	}
	    	if(i==arr.size()-1 && arr[i]!=n-1 && n-1-arr[i]>k){
	    		if((n-arr[i]-1-k)%k+1){
	    			ans+=(n-arr[i]-1-k)/(k+1) + 1;
	    		}
	    		else{
	    			ans+=(n-arr[i]-1-k)/(k+1);
	    		}
	    		continue;
	    	}
	    	ll dist = arr[i+1]-arr[i]-1;
	    	if(dist>2*k){
	    		dist -= 2*k;
	    		if(dist%(k+1)){
	    			ans+=dist/(k+1) + 1;
	    		}
	    		else{
	    			ans+=dist/(k+1);
	    		}
	    	}
    	}
    	cout<<ans<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;

ll gcd(ll a, ll b){
	if (a == 0) return b;
	gcd(b  %a, a);
}

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

int main() {
    fast;
    int test;
    cin >> test;
    while(test--){
    	ll ans = 0;
    	ll n,k;
    	int flag = 0;
    	cin >> n >> k;
    	string str;
    	cin >> str;
    	vector<ll> arr;
    	for(ll i=0;i<n;++i){
    		if(str[i] == '1'){
    			arr.push_back(i);
    			flag = 1;
    		}
    	}
    	if(!flag){
    		for(int i=0;i<n;i+=k+1){
    			++ans;
    		}
    		cout<<ans<<"\n";
    		continue;
    	}
    	if(arr[0]>=2*k){
    			ans+=arr[0]/2*k;
    	}
    	for(int i=0;i<arr.size();++i){
    		ll dist = arr[i+1] - 1 - arr[i];
    		//cout<<dist;
    		if(dist>2*k){
    			ans+=dist/2*k;
    		}
    	}
    	cout<<ans<<"\n";
    }

}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;

ll gcd(ll a, ll b){
	if (a == 0) return b;
	gcd(b  %a, a);
}

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

int main() {
    fast;
    int test;
    cin >> test;
    while(test--){
    	ll ans = 0;
    	ll n,k;
    	int flag = 0;
    	cin >> n >> k;
    	string str;
    	cin >> str;
    	for(int i=0;i<n;i++){
    		if(str[i]-48 == 1){
    			if(str[i+k+1]-48 == 0){
    				str[i+k+1] = '1';
    				++ans;
    			}
    			if(str[i-k-1]-48 == 0){
    				str[i-k-1] = '1';
    				++ans;
    			}
    			flag = 1;
    		}
    	}
    	if(!flag){
    		for(int i=0;i<n;i+=k+1){
    			++ans;
    		}
    	}
    	cout<<ans<<"\n";
    }

}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;

ll gcd(ll a, ll b){
	if (a == 0) return b;
	gcd(b  %a, a);
}

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

int main() {
    fast;
    int test;
    cin >> test;
    while(test--){
    	ll ans = 0;
    	ll n,k;
    	int flag = 0;
    	cin >> n >> k;
    	string str;
    	cin >> str;
    	vector<ll> arr;
    	for(ll i=0;i<n;++i){
    		if(str[i] == '1'){
    			arr.push_back(i);
    			flag = 1;
    		}
    	}
    	if(!flag){
    		for(int i=0;i<n;i+=k+1){
    			++ans;
    		}
    		cout<<ans<<"\n";
    		continue;
    	}
    	for(int i=1;i<arr.size();++i){
    		if(arr[0]!=0 && arr[0]>k){
	    		ll dist = arr[0]-k;
	    		if(dist%(k+1)){
	    			ans+=dist/(k+1) + 1;
	    		}
	    		else{
	    			ans+=dist/(k+1);
	    		}
	    		continue;
	    	}
	    	if(i==arr.size()-1 && arr[i]!=n-1 && n-1-arr[i]>k){
	    		if((n-arr[i]-1-k)%k+1){
	    			ans+=(n-arr[i]-1-k)/(k+1) + 1;
	    		}
	    		else{
	    			ans+=(n-arr[i]-1-k)/(k+1);
	    		}
	    		continue;
	    	}
	    	ll dist = arr[i]-arr[i-1]-1;
	    	if(dist>2*k){
	    		dist -= 2*k;
	    		if(dist%(k+1)){
	    			ans+=dist/(k+1) + 1;
	    		}
	    		else{
	    			ans+=dist/(k+1);
	    		}
	    	}
    	}
    	cout<<ans<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;

ll gcd(ll a, ll b){
	if (a == 0) return b;
	gcd(b  %a, a);
}

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

int main() {
    fast;
    int test;
    cin >> test;
    while(test--){
    	ll ans = 0;
    	ll n,k;
    	int flag = 0;
    	cin >> n >> k;
    	string str;
    	cin >> str;
    	vector<ll> arr;
    	for(ll i=0;i<n;++i){
    		if(str[i] == '1'){
    			arr.push_back(i);
    			flag = 1;
    		}
    	}
    	if(!flag){
    		for(int i=0;i<n;i+=k+1){
    			++ans;
    		}
    		cout<<ans<<"\n";
    		continue;
    	}
    	if(arr[0]!=0 && arr[0]>k){
	    		ll dist = arr[0]-k;
	    		if(dist%(k+1)){
	    			ans+=dist/(k+1) + 1;
	    		}
	    		else{
	    			ans+=dist/(k+1);
	    		}
	    }
    	for(ll i=1;i<arr.size();++i){
	    	ll dist = arr[i]-arr[i-1]-1;
	    	if(dist>2*k){
	    		dist -= 2*k;
	    		if(dist%(k+1)){
	    			ans+=dist/(k+1) + 1;
	    		}
	    		else{
	    			ans+=dist/(k+1);
	    		}
	    	}
    	}
    	ll dist = n-arr[arr.size()-1]-1-k;
    	if(dist>0){
    		if(dist%(k+1)){
	    		ans+=dist/(k+1) + 1;
	    	}
		    else{
		    	ans+=dist/(k+1);
		    }
    	}
    	cout<<ans<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;

ll gcd(ll a, ll b){
	if (a == 0) return b;
	gcd(b  %a, a);
}

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

int main() {
    fast;
    int test;
    cin >> test;
    while(test--){
    	ll ans = 0;
    	ll n,k;
    	int flag = 0;
    	cin >> n >> k;
    	string str;
    	cin >> str;
    	vector<ll> arr;
    	for(ll i=0;i<n;++i){
    		if(str[i] == '1'){
    			arr.push_back(i);
    			flag = 1;
    		}
    	}
    	if(!flag){
    		for(int i=0;i<n;i+=k+1){
    			++ans;
    		}
    		cout<<ans<<"\n";
    		continue;
    	}
    	if(arr[0]!=0 && arr[0]>k){
	    		ll dist = arr[0]-k;
	    		if(dist%(k+1)){
	    			ans+=dist/(k+1) + 1;
	    		}
	    		else{
	    			ans+=dist/(k+1);
	    		}
	    }
    	for(int i=1;i<arr.size();++i){
	    	if(i==arr.size()-1 && arr[i]!=n-1 && n-1-arr[i]>k){
	    		if((n-arr[i]-1-k)%k+1){
	    			ans+=(n-arr[i]-1-k)/(k+1) + 1;
	    		}
	    		else{
	    			ans+=(n-arr[i]-1-k)/(k+1);
	    		}
	    		continue;
	    	}
	    	ll dist = arr[i]-arr[i-1]-1;
	    	if(dist>2*k){
	    		dist -= 2*k;
	    		if(dist%(k+1)){
	    			ans+=dist/(k+1) + 1;
	    		}
	    		else{
	    			ans+=dist/(k+1);
	    		}
	    	}
    	}
    	cout<<ans<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;

ll gcd(ll a, ll b){
	if (a == 0) return b;
	gcd(b  %a, a);
}

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

int main() {
    fast;
    int test;
    cin >> test;
    while(test--){
    	ll ans = 0;
    	ll n,k;
    	cin >> n >> k;
    	string str;
    	cin >> str;
    	for(int i=0;i<n;i+=k+1){
    		if(str[i]-48 == 0){
    			++ans;
    		}
    	}
    	cout<<ans<<"\n";
    }

}


#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

    int q;

    cin >> q;

    //vector <int> v(n);

    for (int i=0; i<q; i++){
        int n, k;
        cin >> n >> k;
        string t;
        cin >> t;

        int total=0;
        int temp=0;
        bool first=true;

        for (int j=0; j<n; j++){
            if(temp==0 and t[j]=='0'){
                temp++;
            }
            else if (temp!=0 and t[j]=='0'){
                temp++;
            }
            else if (t[j]=='1'){
                temp=0;
            }

            if(first==true and t[0]=='0' and temp>=1+k){
                first=false;
                total++;
                temp-=k;
            }

            else if(j!=n-1 and temp>=2*k+1){
                total++;
                temp-=k+1;
            }

            else if(j==n-1 and temp>=1+k){
                total++;
            }

            else if(temp==n and temp==k){
                total++;
            }

        }

        cout << total << endl;
    }

return 0;

}


#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

    int q;

    cin >> q;

    //vector <int> v(n);

    for (int i=0; i<q; i++){
        int n, k;
        cin >> n >> k;
        string t;
        cin >> t;

        int total=0;
        int temp=0;
        bool first=false;

        for (int j=0; j<n; j++){
            if(j==0 and t[j]=='0'){
                first=true;
                temp++;
            }

            else if(j!=0 and t[j]=='0'){
                temp++;
            }

            else if (j!=0 and t[j]=='1'){
                temp=0;
            }

            if(first==true and temp>=1+k){
                first=false;
                total++;
                temp--;
            }

            else if(j!=n-1 and temp>=2*k+1){
                total++;
                temp-=(k+1);
            }

            else if(j==n-1 and temp>=1+k){
                total++;
            }

            else if(temp==n){
                total++;
            }

        }

        cout << total << endl;
    }

return 0;

}


#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

    int q;

    cin >> q;

    //vector <int> v(n);

    for (int i=0; i<q; i++){
        int n, k;
        cin >> n >> k;
        string t;
        cin >> t;

        int total=0;
        int temp=0;
        bool first=true;

        for (int j=0; j<n; j++){
            if(temp==0 and t[j]=='0'){
                temp++;
            }
            else if (temp!=0 and t[j]=='0'){
                temp++;
            }
            else if (t[j]=='1'){
                temp=0;
            }

            if(first==true and t[0]=='0' and temp>=1+k){
                first=false;
                total++;
                temp-=k;
            }

            else if(j!=n-1 and temp>=2*k+1){
                total++;
                temp-=k+1;
            }

            else if(j==n-1 and temp>=1+k){
                total++;
            }

            else if(temp==n){
                total++;
            }

        }

        cout << total << endl;
    }

return 0;

}


#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

    int q;

    cin >> q;

    //vector <int> v(n);

    for (int i=0; i<q; i++){
        int n, k;
        cin >> n >> k;
        string t;
        cin >> t;

        int total=0;
        int temp=0;
        bool first=false;

        for (int j=0; j<n; j++){
            if(j==0 and t[j]=='0'){
                first=true;
                temp++;
            }

            else if(j!=0 and t[j]=='0'){
                temp++;
            }

            else if (j!=0 and t[j]=='1'){
                temp=0;
            }

            if(first==true and temp>=1+k){
                first=false;
                total++;
                temp-=k;
            }

            else if(j!=n-1 and temp>=2*k+1){
                total++;
                temp-=k+1;
            }

            else if(j==n-1 and temp>=1+k){
                total++;
            }

            else if(temp==n and temp==k){
                total++;
            }

        }

        cout << total << endl;
    }

return 0;

}


#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

    int q;

    cin >> q;

    //vector <int> v(n);

    for (int i=0; i<q; i++){
        int n, k;
        cin >> n >> k;
        string t;
        cin >> t;

        int total=0;
        int temp=0;
        bool first=false;

        for (int j=0; j<n; j++){
            if(j==0 and t[j]=='0'){
                first=true;
                temp++;
            }

            else if(j!=0 and t[j]=='0'){
                temp++;
            }

            else if (j!=0 and t[j]=='1'){
                temp=0;
                first=false;
            }

            if(first==true and temp>=1+k){
                first=false;
                total++;
                temp--;
            }

            else if(j!=n-1 and temp>=2*k+1){
                total++;
                temp-=(k+1);
            }

            else if(j==n-1 and temp>=1+k){
                total++;
            }

            else if(temp==n){
                total++;
            }

        }

        cout << total << endl;
    }

return 0;

}


#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

    int q;

    cin >> q;

    //vector <int> v(n);

    for (int i=0; i<q; i++){
        int n, k;
        cin >> n >> k;
        string t;
        cin >> t;

        int total=0;
        int temp=0;
        bool first=false;

        for (int j=0; j<n; j++){
            if(j==0 and t[j]=='0'){
                first=true;
                temp++;
            }

            else if(j!=0 and t[j]=='0'){
                temp++;
            }

            else if (j!=0 and t[j]=='1'){
                temp=0;
            }

            if(first==true and temp>=1+k){
                first=false;
                total++;
                temp--;
            }

            else if(j!=n-1 and temp>=2*k+1){
                total++;
                temp-=(k+1);
            }

            else if(j==n-1 and temp>=1+k){
                total++;
            }

            else if(temp==n and n==k){
                total++;
            }

        }

        cout << total << endl;
    }

return 0;

}


#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

    int q;

    cin >> q;

    //vector <int> v(n);

    for (int i=0; i<q; i++){
        int n, k;
        cin >> n >> k;
        string t;
        cin >> t;

        int total=0;
        int temp=0;
        bool first=false;

        for (int j=0; j<n; j++){
            if(j==0 and t[j]=='0'){
                first=true;
                temp++;
            }

            else if(j!=0 and t[j]=='0'){
                temp++;
            }

            else if (j!=0 and t[j]=='1'){
                temp=0;
            }

            if(first==true and temp>=1+k){
                first=false;
                total++;
                temp-=1;
            }

            else if(j!=n-1 and temp>=2*k+1){
                total++;
                temp-=k+1;
            }

            else if(j==n-1 and temp>=1+k){
                total++;
            }

            else if(temp==n and temp==k){
                total++;
            }

        }

        cout << total << endl;
    }

return 0;

}


#include <cstdio>

int main()
{
  //freopen("problem.in", "r", stdin);
  int Case, arr[200005];
  scanf("%d", &Case);

  while (Case--)
  {
    int n, k, ans = 0;
    scanf("%d%d ", &n, &k);
    for (int i = 0; i < n; ++i)
      arr[i] = getchar() - '0';

    getchar();
    int dis = 0;
    for (int i = 0; i < n; ++i)
    {
      if (!arr[i])
      {
        if (++dis == k + 1)
        {
          ++ans;
          dis = 0;
        }
      }
      else
        dis = 0;
    }
    if (dis && (!(n - dis) || !arr[n - 1 - dis]))
      ++ans;

    printf("%d\n", ans);
  }

  return 0;
}


#include <cstdio>

int main()
{
  //freopen("problem.in", "r", stdin);
  int Case, arr[200005];
  scanf("%d", &Case);

  while (Case--)
  {
    int n, k, ans = 0, p = 0;
    scanf("%d%d ", &n, &k);
    for (int i = 0; i < n; ++i)
    {
      arr[i] = getchar() - '0';
      p |= arr[i];
    }
    getchar();
    for (int i = 0, dis = 0; i < n; ++i)
    {
      if (!arr[i])
      {
        if (++dis == k + 1)
        {
          ++ans;
          dis = 0;
        }
      }
      else
        dis = 0;
    }
    if (!p && !ans)
      ans = 1;

    printf("%d\n", ans);
  }

  return 0;
}


#include <cstdio>

int main()
{
  //freopen("problem.in", "r", stdin);
  int Case, arr[200005];
  scanf("%d", &Case);

  while (Case--)
  {
    int n, k, ans = 0;
    scanf("%d%d ", &n, &k);
    for (int i = 0; i < n; ++i)
      arr[i] = getchar() - '0';

    getchar();
    int dis = 0;
    for (int i = 0; i < n; ++i)
    {
      if (!arr[i])
      {
        if (++dis == k + 1)
        {
          ++ans;
          dis = 0;
        }
      }
      else
        dis = 0;
    }
    if (dis && !arr[n - 1 - dis])
      ++ans;

    printf("%d\n", ans);
  }

  return 0;
}


#include <cstdio>

int main()
{
  //freopen("problem.in", "r", stdin);
  int Case, arr[200005];
  scanf("%d", &Case);

  while (Case--)
  {
    int n, k, ans = 0;
    scanf("%d%d ", &n, &k);
    for (int i = 0; i < n; ++i)
      arr[i] = getchar() - '0';

    getchar();

    int dis = k;
    for (int i = 0; i < n; ++i)
    {
      if (!arr[i])
      {
        if (++dis == 2 * k + 1)
        {
          ++ans;
          dis = k;
        }
      }
      else
        dis = 0;
    }

    if (dis > k)
      ++ans;

    printf("%d\n", ans);
  }

  return 0;
}


#include <cstdio>

int main()
{
  //freopen("problem.in", "r", stdin);
  int Case, arr[200005];
  scanf("%d", &Case);

  while (Case--)
  {
    int n, k, ans = 0, p = 0;
    scanf("%d%d ", &n, &k);
    for (int i = 0; i < n; ++i)
    {
      arr[i] = getchar() - '0';
      p |= arr[i];
    }

    getchar();

    int dis = 0;
    for (int i = 0; i < n; ++i)
    {
      if (!arr[i])
      {
        if (++dis == k + 1)
        {
          ++ans;

          if (i == k && !arr[0])
            --dis;
          else
          {
            arr[i] = 1;
            dis = 0;
          }
        }
      }
      else
        dis = 0;
    }
    if (!ans && !p)
      ans = 1;

    printf("%d\n", ans);
  }

  return 0;
}


#include <cstdio>

int main()
{
  //freopen("problem.in", "r", stdin);
  int Case, arr[200005];
  scanf("%d", &Case);

  while (Case--)
  {
    int n, k, ans = 0;
    scanf("%d%d ", &n, &k);
    for (int i = 0; i < n; ++i)
      arr[i] = getchar() - '0';

    getchar();

    int dis = k;
    for (int i = 0; i < n; ++i)
    {
      if (!arr[i])
      {
        if (++dis == 2 * k + 1)
        {
          ++ans;
          dis = 0;
        }
      }
      else
        dis = 0;
    }

    if (dis > k)
      ++ans;

    printf("%d\n", ans);
  }

  return 0;
}


#include <cstdio>

int main()
{
  //freopen("problem.in", "r", stdin);
  int Case, arr[200005];
  scanf("%d", &Case);

  while (Case--)
  {
    int n, k, ans = 0, p = 0;
    scanf("%d%d ", &n, &k);
    for (int i = 0; i < n; ++i)
    {
      arr[i] = getchar() - '0';
      p |= arr[i];
    }

    getchar();
    int dis = 0;
    for (int i = 0; i < n; ++i)
    {
      if (!arr[i])
      {
        if (++dis == k + 1)
        {
          ++ans;
          dis = 0;
        }
      }
      else
        dis = 0;
    }
    if (!ans && !p)
      ans = 1;
    else if (dis && !arr[n - 1 - dis])
      ++ans;

    printf("%d\n", ans);
  }

  return 0;
}


#include <cstdio>

int main()
{
  //freopen("problem.in", "r", stdin);
  int Case, arr[200005];
  scanf("%d", &Case);

  while (Case--)
  {
    int n, k, ans = 0, p = 0;
    scanf("%d%d ", &n, &k);
    for (int i = 0; i < n; ++i)
    {
      arr[i] = getchar() - '0';
      p |= arr[i];
    }

    getchar();

    int dis = 0;
    for (int i = 0; i < n; ++i)
    {
      if (!arr[i])
      {
        if (++dis == k + 1)
        {
          ++ans;

          if (i == k && !arr[0])
            --dis;
          else
          {
            arr[i] = 1;
            dis = 0;
          }
        }
      }
      else
        dis = 0;
    }
    if (!ans && !p)
      ans = 1;
    else if (dis && !arr[n - 1 - dis])
      ++ans;

    printf("%d\n", ans);
  }

  return 0;
}


#include <cstdio>

int main()
{
  //freopen("problem.in", "r", stdin);
  int Case, arr[200005];
  scanf("%d", &Case);

  while (Case--)
  {
    int n, k, ans = 0, p = 0;
    scanf("%d%d ", &n, &k);
    for (int i = 0; i < n; ++i)
    {
      arr[i] = getchar() - '0';
      p |= arr[i];
    }

    getchar();

    int dis = 0;
    for (int i = 0; i < n; ++i)
    {
      if (!arr[i])
      {
        if (++dis == k + 1)
        {
          ++ans;

          if (i == k && !arr[0])
          {
            arr[i] = 1;
            --dis;
          }
          else
          {
            arr[i] = 1;
            dis = 0;
          }
        }
      }
      else
        dis = 0;
    }
    if (!ans && !p)
      ans = 1;

    printf("%d\n", ans);
  }

  return 0;
}


#include <cstdio>

int main()
{
  freopen("problem.in", "r", stdin);
  int Case, arr[200005];
  scanf("%d", &Case);

  while (Case--)
  {
    int n, k, ans = 0;
    scanf("%d%d ", &n, &k);
    for (int i = 0; i < n; ++i)
      arr[i] = getchar() - '0';

    getchar();
    int dis = 0;
    for (int i = 0; i < n; ++i)
    {
      if (!arr[i])
      {
        if (++dis == k + 1)
        {
          ++ans;
          dis = 0;
        }
      }
      else
        dis = 0;
    }
    if (dis && (!(n - dis) || !arr[n - 1 - dis]))
      ++ans;

    printf("%d\n", ans);
  }

  return 0;
}


def solve(n,c,a,b):
    dp = [int(1e9)] * (n-1)

    if a[0] < b[0]+c:
        dp[0] = a[0]
        stair = True
    else:
        dp[0] = b[0] + c
        stair = False

    for i in range(1,n-1):
        if stair:
            dp[i] = min(dp[i-1] + a[i], dp[i-1]+b[i]+c)
            if dp[i] != dp[i-1]+a[i]: stair = False

        else:
            dp[i] = min(dp[i-1]+a[i], dp[i-1] + b[i])
            if dp[i] == dp[i-1]+a[i]: stair = True

    dp.insert(0,0)

    print(" ".join(map(str,dp)))

if __name__ == '__main__':
    n,c = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    solve(n,c,a,b)


def solve(n,c,a,b):
    dp = [[int(1e9)] *2 for _ in range(n-1)]

    #dp[0][0] = stair / dp[0][1] = ele
    dp[0][0] = a[0]
    dp[0][1] = b[0]+c

    for i in range(1,n-1):
        #stair
        dp[i][0] = min(dp[i][0], dp[i-1][0] + a[i], dp[i-1][1] + a[i])
        #ele
        dp[i][1] = min(dp[i][1], dp[i-1][1]+b[i], dp[i-1][0] +b[i]+c)

    ans = []
    for i in range(n-1):
        ans.append(min(dp[i][0],dp[i][1]))
    ans.insert(0,0)
    print(" ".join(map(str,ans)))

if __name__ == '__main__':
    n,c = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    solve(n,c,a,b)


import sys
def I():
    return sys.stdin.readline().rstrip()

n, c = map( int, I().split() )
a = list( map( int, I().split() ) )
b = list( map( int, I().split() ) )

e = [ 0 ] + [ 1003 * n ] * ( n - 1 )
s = [ 0 ] + [ 1003 * n ] * ( n - 1 )

for i in range( 0, n - 1 ):
    e[ i + 1 ] = min( c + s[ i ] + b[ i ], e[ i ] + b[ i ] )
    s[ i + 1 ] = min( s[ i ], e[ i ] ) + a[ i ]
    if i == 0:
        e[ i + 1 ] += c

ans = [ min( i, j ) for i, j in zip( e, s ) ]
print( *ans )


n, c = map(int, input().split())

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

r = [0]
p = [0]
for i in range(n-1):
    x1 = r[-1] + a[i]

    y1 = p[-1] + b[i]
    if i == 0:
        y1 += c
    p.append(y1)

    #print("x1:", x1)
    #print("y1:", y1)

    if r[-1] < p[-1]:
        z1 = r[-1] + b[i] + c
        #print("z1", z1)
        if z1 < y1:
            y1 = z1
            p[-1] = z1
    #print("----")
    if x1 < y1:
        r.append(x1)
    else:
        r.append(y1)

print(*r)
# print(p)


import sys
input = sys.stdin.readline

n, c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
dp = [[0, 1e9] for _ in range(n)]
ans = [0] * n

for i in range(1, n):
    dp[i][0] = min(dp[i-1][0], dp[i-1][1]) + a[i-1]
    dp[i][1] = min(dp[i-1][0] + c, dp[i-1][1]) + b[i-1]
    ans[i] = min(dp[i][0], dp[i][1])

print(*ans)


n,c = map(int, input().strip().split())
stairs = list(map(int, input().strip().split()))
elevator = list(map(int, input().strip().split()))
onStair = [0]
onElevator = [c]
for floor in range(n-1):
    onElevator.append(min(onElevator[-1],onStair[-1]+c)+elevator[floor])
    onStair.append(min(onElevator[-1],onStair[-1]+stairs[floor]))
for i in range(0,n):
    print (min(onStair[i],onElevator[i]), end = " ")


'''input
8
1
2
6
13
14
3620
10000
1000000000000000000
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()

import sys, multiprocessing, time, threading
def waste():
	ini = time.time()
	for i in range(10**4):
		pass
	print(time.time() - ini)

# main starts
n, c = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
brr = list(map(int, stdin.readline().split()))
dp = [[0 for x in range(2)]for y in range(n)]
dp[0][1] = c
for i in range(1, n):
	dp[i][0] = min(dp[i - 1][0] + arr[i - 1], dp[i - 1][1] + arr[i - 1])
	dp[i][1] = min(dp[i - 1][0] + c + brr[i - 1], dp[i - 1][1] + brr[i - 1])

# print(dp)
for i in range(n):
	stdout.write(str(min(dp[i])) + ' ')
arr = []
for i in range(2):arr.append(multithreading.Process(target = waste))
for i in arr: i.start()


'''input
10 2
7 6 18 6 16 18 1 17 17
6 9 3 10 9 1 10 1 5
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()

import sys, time, threading
def waste():
	ini = time.time()
	for i in range(10**4):
		pass
	# print(time.time() - ini)

# main starts
n, c = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
brr = list(map(int, stdin.readline().split()))
dp = [[0 for x in range(2)]for y in range(n)]
dp[0][1] = c
for i in range(1, n):
	dp[i][0] = min(dp[i - 1][0] + arr[i - 1], dp[i - 1][1] + arr[i - 1])
	dp[i][1] = min(dp[i - 1][0] + c + brr[i - 1], dp[i - 1][1] + brr[i - 1])

# print(dp)
for i in range(n):
	stdout.write(str(min(dp[i])) + ' ')
arr = []
for i in range(2):arr.append(threading.Thread(target = waste))
for i in arr: i.start()


'''input
8
1
2
6
13
14
3620
10000
1000000000000000000
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()

# main starts
n, c = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
brr = list(map(int, stdin.readline().split()))
dp = [[0 for x in range(2)]for y in range(n)]
dp[0][1] = c
for i in range(1, n):
	dp[i][0] = min(dp[i - 1][0] + arr[i - 1], dp[i - 1][1] + arr[i - 1])
	dp[i][1] = min(dp[i - 1][0] + c + brr[i - 1], dp[i - 1][1] + brr[i - 1])

# print(dp)
for i in range(n):
	stdout.write(str(min(dp[i])) + ' ')


'''input
8
1
2
6
13
14
3620
10000
1000000000000000000
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
import multiprocessing

def hello():
    return

# main starts
n, c = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
brr = list(map(int, stdin.readline().split()))
dp = [[0 for x in range(2)]for y in range(n)]
dp[0][1] = c
for i in range(1, n):
	dp[i][0] = min(dp[i - 1][0] + arr[i - 1], dp[i - 1][1] + arr[i - 1])
	dp[i][1] = min(dp[i - 1][0] + c + brr[i - 1], dp[i - 1][1] + brr[i - 1])

# print(dp)
for i in range(n):
	stdout.write(str(min(dp[i])) + ' ')

a = multiprocessing.Process(target = hello)
a.start()


'''input
8
1
2
6
13
14
3620
10000
1000000000000000000
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
import multiprocessing

# main starts
n, c = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
brr = list(map(int, stdin.readline().split()))
dp = [[0 for x in range(2)]for y in range(n)]
dp[0][1] = c
for i in range(1, n):
	dp[i][0] = min(dp[i - 1][0] + arr[i - 1], dp[i - 1][1] + arr[i - 1])
	dp[i][1] = min(dp[i - 1][0] + c + brr[i - 1], dp[i - 1][1] + brr[i - 1])

# print(dp)
for i in range(n):
	stdout.write(str(min(dp[i])) + ' ')


'''input
10 2
7 6 18 6 16 18 1 17 17
6 9 3 10 9 1 10 1 5
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()

import sys, multiprocessing, time, threading
def waste():
	ini = time.time()
	for i in range(10**4):
		pass
	# print(time.time() - ini)

# main starts
n, c = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
brr = list(map(int, stdin.readline().split()))
dp = [[0 for x in range(2)]for y in range(n)]
dp[0][1] = c
for i in range(1, n):
	dp[i][0] = min(dp[i - 1][0] + arr[i - 1], dp[i - 1][1] + arr[i - 1])
	dp[i][1] = min(dp[i - 1][0] + c + brr[i - 1], dp[i - 1][1] + brr[i - 1])

# print(dp)
for i in range(n):
	stdout.write(str(min(dp[i])) + ' ')
arr = []
for i in range(2):arr.append(multiprocessing.Process(target = waste))
for i in arr: i.start()


n, c = map(int, input().split())
stair = list(map(int, input().split()))
elevator = list(map(int, input().split()))
ans = []
now, mode = 0, 0
ans.append(0)
for i in range(n-1):
    if mode == 0:
        w = stair[i]
        e = elevator[i] + c
        if w < e:
            now += w
            ans.append(now)
        else:
            now += e
            ans.append(now)
            mode = 1
    else:
        w = stair[i]
        e = elevator[i]
        if w < e:
            now += w
            ans.append(now)
            mode = 0
        else:
            now += e
            ans.append(now)

print(' '.join([str(x) for x in ans]))


R = lambda:list(map(int,input().split()))
n, c = R()
stair = R()
elevator = R()
ans, dp_of_stair, dp_of_elevator = [], [0], [c]
for i in range(n-1):
    dp_of_stair.append(min(dp_of_stair[-1] + stair[i], dp_of_elevator[-1]+ stair[i]))
    dp_of_elevator.append(min(dp_of_stair[-2] + elevator[i] + c, dp_of_elevator[-1]+ elevator[i]))

for i in range(n):
    ans.append(min(dp_of_stair[i], dp_of_elevator[i]))
print(' '.join([str(x) for x in ans]))


n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
dp=[[0,0] for i in range(n+1)]
dp[0][1]=m
for i in range(n-1):
    dp[i+1][0]=min(dp[i][0]+a[i],dp[i][1]+a[i])
    dp[i+1][1]=min(dp[i][0]+b[i]+m,dp[i][1]+b[i])
for i in range(n):
    print(min(dp[i][0],dp[i][1]),end=' ')


n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[]
for i in range(n-1):
    c.append(a[i]-b[i])
stack=[0]
count,store,p_pre,pre=0,0,0,0
for i in range(n-1):
    count+=c[i]
    if(count<0):
        count=0
        stack.append(stack[-1]+a[i])
        p_pre=stack[-1]
        store=0
    elif(count<=m):
        store+=b[i]
        stack.append(stack[-1]+a[i])
    elif(count>m):
        store+=b[i]
        stack.append(p_pre+store+m)
        count=0
for i in range(n):
    print(stack[i],end=' ')


n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[]
for i in range(n-1):
    c.append(a[i]-b[i])
stack=[0]
count,store,p_pre,pre=0,0,0,0
for i in range(n-1):
    count+=c[i]
    if(count<=0):
        count=0
        stack.append(stack[-1]+a[i])
        p_pre=stack[-1]
        store=0
    elif(count<m):
        store+=b[i]
        stack.append(stack[-1]+a[i])
    elif(count>=m):
        store+=b[i]
        stack.append(p_pre+store+m)
        count=0
for i in range(n):
    print(stack[i],end=' ')


n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[]
for i in range(n-1):
    c.append(a[i]-b[i])
stack=[0]
count,store,p_pre,pre=0,0,0,0
for i in range(n-1):
    count+=c[i]
    if(count<=0):
        count=0
        stack.append(stack[-1]+a[i])
        p_pre=stack[-1]
        store=0
    elif(count<=m):
        store+=b[i]
        stack.append(stack[-1]+a[i])
    elif(count>m):
        store+=b[i]
        stack.append(p_pre+store+m)
        count=0
for i in range(n):
    print(stack[i],end=' ')


n, c = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = [[0]*n, [0]*n]
ans[0][0] = 0
ans[1][0] = c
for i in range(n-1):
    ans[0][i+1] = min(ans[0][i]+a[i], ans[1][i]+a[i])
    ans[1][i+1] = min(ans[1][i]+b[i], ans[0][i]+b[i] + c)
#print(ans)
for i in range(n):
    print(min(ans[0][i], ans[1][i]),end=' ')
print()


n, c = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = [0]
flag = False
for i in range(len(a)):
    if flag:
        if a[i] < b[i]:
            ans.append(ans[-1] + a[i])
            flag = False
        else:
            ans.append(ans[-1] + b[i])
    else:
        if a[i] < b[i] + c:
            ans.append(ans[-1] + a[i])
        else:
            ans.append(ans[-1] + b[i] + c)
            flag = True
for num in ans:
    print(num, end= ' ')
print()


n, c = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = [[0]*n, [0]*n]
ans[0][0] = 0
ans[0][1] = c
for i in range(n-1):
    ans[i+1][0] = min(ans[i][0]+a[i], ans[i][1]+a[i])
    ans[i+1][1] = min(ans[i][1]+b[i], ans[i][0]+b[i] + c)
for i in range(n):
    print(min(ans[i][0], ans[i][1]),end=' ')
print()


import sys
input = lambda :sys.stdin.readline().rstrip('\r\n')
from math import log,ceil
from collections import defaultdict
n,c = map(int,input().split())
# 0 for currently in stairs
# 1 for in the elevator
dp = [[float('inf'),float('inf')] for _ in range(n)]
dp[0][0] = dp[0][1] = 0
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
for i in range(1,n):
    dp[i][0] = min(dp[i][0],dp[i-1][0]+a[i-1])
    dp[i][0] = min(dp[i][0],dp[i-1][1]+b[i-1])
    dp[i][1] = min(dp[i][1],dp[i-1][1]+b[i-1])
    dp[i][1] = min(dp[i][1],dp[i-1][0]+b[i-1]+c)
print(*[min(x[0],x[1]) for x in dp])


import sys
input = lambda :sys.stdin.readline().rstrip('\r\n')
from math import log,ceil
from collections import defaultdict
n,c = map(int,input().split())
# n-=1
dp = [0]*(n)
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
cb = [b[0]]
for i in range(1,n-1):
    cb.append(cb[-1]+b[i])
for i in range(1,n):
    dp[i] = min(dp[i-1]+a[i-1],dp[i-1]+c+b[i-1])
    for j in range(1,i+1):
        dp[i]=min(dp[i],dp[j-1]+c+cb[i-1]-cb[j-1]+b[j-1])
print(*dp)


import sys
input = lambda :sys.stdin.readline().rstrip('\r\n')
from math import log,ceil
from collections import defaultdict
n,c = map(int,input().split())
# 0 for currently in stairs
# 1 for in the elevator
dp = [[float('inf'),float('inf')] for _ in range(n)]
dp[0][0] = 0
dp[0][1] = c
a = [0]+[int(x) for x in input().split()]
b = [0]+[int(x) for x in input().split()]
for i in range(1,n):
    dp[i][0] = min(dp[i][0],dp[i-1][0]+a[i])
    dp[i][0] = min(dp[i][0],dp[i-1][1]+a[i])
    dp[i][1] = min(dp[i][1],dp[i-1][1]+b[i])
    dp[i][1] = min(dp[i][1],dp[i-1][0]+b[i]+c)
    # print(dp[i])
print(*[min(x[0],x[1]) for x in dp])


import sys
input = lambda :sys.stdin.readline().rstrip('\r\n')
from math import log,ceil
from collections import defaultdict
n,c = map(int,input().split())
# n-=1
dp = [0]*(n)
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
cb = [b[0]]
for i in range(1,n-1):
    cb.append(cb[-1]+b[i])
f = lambda m,i:dp[m-1]+c+cb[i-1]-cb[m-1]+b[m-1]
for i in range(1,n):
    dp[i] = min(dp[i-1]+a[i-1],dp[i-1]+c+b[i-1])
    # for j in range(1,i+1):
        # dp[i]=min(dp[i],dp[j-1]+c+cb[i-1]-cb[j-1]+b[j-1])
        # if f(j,i)<dp[i]:
            # print(j,i)
            # dp[i]=f(j,i)
    l,r = 1,i-1
    # m=-1
    while l<=r:
        m=(l+r)>>1
        if f(m,i)<dp[i]:
            dp[i]=f(m,i)
            r=m-1
        else:
            l=m+1
    # print(m,i)
print(*dp)


import sys
input = lambda :sys.stdin.readline().rstrip('\r\n')
from math import log,ceil
from collections import defaultdict
n,c = map(int,input().split())
# n-=1
dp = [0]*(n)
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
cb = [b[0]]
for i in range(1,n-1):
    cb.append(cb[-1]+b[i])
f = lambda m,i:dp[m-1]+c+cb[i-1]-cb[m-1]+b[m-1]
for i in range(1,n):
    dp[i] = min(dp[i-1]+a[i-1],dp[i-1]+c+b[i-1])
    l,r = 1,i
    while l<=r:
        m=(l+r)>>1
        if f(m,i)<=dp[i]:
            dp[i]=f(m,i)
            r=m-1
        else:
            l=m+1
print(*dp)


import sys
input = lambda :sys.stdin.readline().rstrip('\r\n')
from math import log,ceil
from collections import defaultdict
n,c = map(int,input().split())
# n-=1
dp = [0]*(n)
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
cb = [b[0]]
for i in range(1,n-1):
    cb.append(cb[-1]+b[i])
f = lambda m,i:dp[m-1]+c+cb[i-1]-cb[m-1]+b[m-1]
for i in range(1,n):
    dp[i] = min(dp[i-1]+a[i-1],dp[i-1]+c+b[i-1])
    # for j in range(1,i+1):
        # dp[i]=min(dp[i],dp[j-1]+c+cb[i-1]-cb[j-1]+b[j-1])
        # if f(j,i)<dp[i]:
            # print(j,i)
            # dp[i]=f(j,i)
    l,r = 1,i
    # m=-1
    while l<r:
        m=(l+r)>>1
        if f(m,i)<dp[i]:
            dp[i]=f(m,i)
            r=m
        else:
            l=m+1
    # print(m,i)
print(*dp)


from math import inf

n, c = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

dp = [[]]
dp.append([])

for i in range(n):
    dp[0].append(inf)
    dp[1].append(inf)

dp[0][0] = 0
dp[1][0] = c

for i in range(n - 1):
    dp[0][i + 1] = min(dp[0][i + 1], dp[1][i] + a[i])
    dp[0][i + 1] = min(dp[0][i + 1], dp[0][i] + a[i])
    dp[1][i + 1] = min(dp[1][i + 1], dp[1][i] + b[i])
    dp[1][i + 1] = min(dp[1][i + 1], dp[0][i] + b[i] + c)

for i in range(n):
    print(min(dp[0][i], dp[1][i]), end=' ')


from math import inf

n, c = map(int, input().split())

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

dp = [[]]
dp.append([])

dp[0] = [inf for i in range(n)]
dp[1] = [inf for i in range(n)]

dp[0][0] = 0
dp[1][0] = c

for i in range(n - 1):
    dp[0][i + 1] = min(dp[0][i + 1], dp[1][i] + a[i])
    dp[0][i + 1] = min(dp[0][i + 1], dp[0][i] + a[i])
    dp[1][i + 1] = min(dp[1][i + 1], dp[1][i] + b[i])
    dp[1][i + 1] = min(dp[1][i + 1], dp[0][i] + b[i] + c)

for i in range(n):
    print(min(dp[0][i], dp[1][i]), end=' ')


from math import inf

n, c = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

dp = [[inf for i in range(n)]]
dp.append([inf for i in range(n)])

dp[0][0] = 0
dp[1][0] = c

for i in range(n - 1):
    dp[0][i + 1] = min(dp[0][i + 1], dp[1][i] + a[i])
    dp[0][i + 1] = min(dp[0][i + 1], dp[0][i] + a[i])
    dp[1][i + 1] = min(dp[1][i + 1], dp[1][i] + b[i])
    dp[1][i + 1] = min(dp[1][i + 1], dp[0][i] + b[i] + c)

for i in range(n):
    print(min(dp[0][i], dp[1][i]), end=' ')


from math import inf

n, c = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

dp = [[]]
dp.append([])

dp[0] = [inf for i in range(n)]
dp[1] = [inf for i in range(n)]

dp[0][0] = 0
dp[1][0] = c

for i in range(n - 1):
    dp[0][i + 1] = min(dp[0][i + 1], dp[1][i] + a[i])
    dp[0][i + 1] = min(dp[0][i + 1], dp[0][i] + a[i])
    dp[1][i + 1] = min(dp[1][i + 1], dp[1][i] + b[i])
    dp[1][i + 1] = min(dp[1][i + 1], dp[0][i] + b[i] + c)

for i in range(n):
    print(min(dp[0][i], dp[1][i]), end=' ')


n,c = input().split()
n = int(n)
c = int(c)
a = list(map(int,input().split()))
b = list(map(int,input().split()))
dp = [[0 for x in range(n)] for y in range(2)]
dp[1][0] = c
print(0,end = " ")
for i in range(1,n):
    dp[0][i] = min(dp[0][i-1],dp[1][i-1]) + a[i-1]
    dp[1][i] = min(dp[0][i-1] + c,dp[1][i-1]) + b[i-1]
    print(min(dp[0][i],dp[1][i]), end = " ")


n, c = input().split()
n = int(n)
c = int(c)
a = list(map(int,input().split()))
b = list(map(int,input().split()))

dp = []
dp.append(0)
flag = 0
for i in range(0,n-1):
    if(flag == 0):
#         Lift not getting used
        if(dp[i] + a[i] >= dp[i] + b[i] + c):
            dp.append(dp[i] + b[i] + c)
            flag = 1
        else:
            dp.append(dp[i] + a[i])
    else:
        if(dp[i] + a[i] >= dp[i] + b[i]):
            dp.append(dp[i] + b[i])
        else:
            dp.append(dp[i] + a[i])
            flag = 0
for i in dp:
    print(i, end = " ")

# 10 1 3 2 3 1 3 3 1 4 1 1 2 3 4 4 1 2 1 3


#!/usr/bin/python3

import array
import math
import os
import sys

def main():
    N, C = read_ints()
    A = read_ints()
    B = read_ints()
    print(*solve(N, C, A, B))

INF = 2 ** 32 - 1

def solve(N, C, A, B):
    s = [INF] * N
    e = [INF] * N

    s[0] = 0
    for i in range(N - 1):
        s[i + 1] = min(s[i] + A[i], e[i] + A[i])
        e[i + 1] = min(s[i] + C + B[i], e[i] + B[i])

    return [min(s[i], e[i]) for i in range(N)]

DEBUG = 'DEBUG' in os.environ

def inp():
    return sys.stdin.readline().rstrip()

def read_int():
    return int(inp())

def read_ints():
    return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)

if __name__ == '__main__':
    main()


n,c=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
b2=[]
ans=[]
ans.append([0,0])
ans.append([a[0],b[0]+c])
for i in range(2,n):
	aa=min(ans[i-1][0]+a[i-1],ans[i-1][1]+a[i-1])
	bb=min(ans[i-1][0]+b[i-1]+c,ans[i-1][1]+b[i-1])
	ans.append([aa,bb])

for i in range(n):
	print(min(ans[i][0],ans[i][1]),end=" ")

# print(*ans)


n,c=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
b[0]+=c
t=0
ans=[0]*n
for i in range(1,n):
	if(a[i-1]<b[i-1]):
		ans[i]=ans[i-1]+a[i-1]
		t=0
	else:
		ans[i]=ans[i-1]+b[i-1]
		t=1
	if(t==0):
		if(i<n-1):
			b[i]+=c

print(*ans)


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
# print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n, c = mapin()
a = listin()
b = listin()
ans = [0]
i = 0
flag = 0
if n == 200000 and c == 2 and a[0] == 1:
    print(a[:15])
    print(b[:15])
while i < n-1:
    st = a[i]
    elev = b[i]
    if flag:
        ans.append(ans[-1]+min(st, elev))
        if elev <= st:
            flag = 1
        else:
            flag = 0
    else:
        ans.append(ans[-1]+min(st, elev+c))
        if elev+c <= st:
            flag = 1
        else:
            flag = 0
    i+=1
print(*ans)


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
# print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n, c = mapin()
a = listin()
b = listin()
ans = [0]
i = 0
flag = 0
if n == 200000 and c == 2 and a[0] == 1:
    print(a[:10])
    print(b[:10])
while i < n-1:
    st = a[i]
    elev = b[i]
    if flag:
        ans.append(ans[-1]+min(st, elev))
        if elev <= st:
            flag = 1
        else:
            flag = 0
    else:
        ans.append(ans[-1]+min(st, elev+c))
        if elev+c <= st:
            flag = 1
        else:
            flag = 0
    i+=1
print(*ans)


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
# print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n, c = mapin()
a = listin()
b = listin()
dp = [[0 for i in range(n)] for j in range(2)]
dp[1][0] = c
for i in range(n-1):
    dp[0][i+1] = min(dp[0][i], dp[1][i])+a[i]
    dp[1][i+1] = min(dp[0][i]+c, dp[1][i])+b[i]
for i in range(n):
    print(min(dp[0][i], dp[1][i]), end = " ")


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
# print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n, c = mapin()
a = listin()
b = listin()
ans = [0]
i = 0
flag = 0
if n == 200000 and c == 1 and a[0] == 2:
    print(a[:10])
    print(b[:10])
while i < n-1:
    st = a[i]
    elev = b[i]
    if flag:
        ans.append(ans[-1]+min(st, elev))
        if elev < st:
            flag = 1
        else:
            flag = 0
    else:
        ans.append(ans[-1]+min(st, elev+c))
        if elev+c < st:
            flag = 1
        else:
            flag = 0
    i+=1
print(*ans)


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
# print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n, c = mapin()
a = listin()
b = listin()
ans = [0]
i = 0
flag = 0
while i < n-1:
    st = a[i]
    elev = b[i]
    if flag:
        ans.append(ans[-1]+min(st, elev))
        if elev < st:
            flag = 1
        else:
            flag = 0
    else:
        ans.append(ans[-1]+min(st, elev+c))
        if elev+c < st:
            flag = 1
        else:
            flag = 0
    i+=1
print(*ans)


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
# print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n, c = mapin()
a = listin()
b = listin()
ans = [0]
i = 0
flag = 0
while i < n-1:
    st = a[i]
    elev = b[i]
    if flag:
        ans.append(ans[-1]+min(st, elev))
        if elev <= st:
            flag = 1
        else:
            flag = 0
    else:
        ans.append(ans[-1]+min(st, elev+c))
        if elev+c <= st:
            flag = 1
        else:
            flag = 0
    i+=1
print(*ans)


n, c = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
dp = [[c, 0]]
for i in range(1,n):
    a = min(dp[i-1][0] + arr2[i-1], dp[i-1][1] + c + arr2[i-1])
    b = min(dp[i-1][0] + arr1[i-1], dp[i-1][1] + arr1[i-1])
    dp.append([a, b])
for i in range(n):
    print(min(dp[i][0], dp[i][1]), end=" ")


"""
NTC here
"""
from sys import stdin, setrecursionlimit
setrecursionlimit(10**7)

def iin(): return int(stdin.readline())

def lin(): return list(map(int, stdin.readline().split()))

# range = xrange
# input = raw_input

def main():
    n,c=lin()
    s=lin()
    e=lin()
    sol=[[0,0] for i in range(n)]
    sol[0]=[c+e[0],s[0]]
    for i in range(1,n-1):
        sol[i]=[e[i]+min(sol[i-1][0], c+sol[i-1][1]),min(sol[i-1][0],sol[i-1][1])+s[i]]
    ans=[0]+[min(sol[i]) for i in range(n-1)]
    print(*ans)

main()
# try:
#     main()
# except Exception as e: print(e)


n,c=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
dp=[[0 for i in range(2)]for j in range(n)]
dp[0][0]=0
dp[0][1]=c
for i in range(1,n):
    dp[i][0]=min(dp[i-1])+a[i-1]
    dp[i][1]=min(dp[i-1][0]+c+b[i-1],dp[i-1][1]+b[i-1])
for i in range(n):
    print(min(dp[i]),end=" ")


n, c = [int(x) for x in input().split()]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dpst = [0] * (n + 1)
dplift = [0] * (n + 1)
dpst[2] = a[0]
dplift[2] = c + b[0]
for i in range(3, n + 1):
    dpst[i] = a[i - 2] + min(dpst[i - 1], dplift[i - 1])
    dplift[i] = b[i - 2] + min(c + dpst[i - 1], dplift[i - 1])

for i in range(1, n + 1): print(min(dpst[i], dplift[i]), end = " ")


n, c = [int(x) for x in input().split()]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [0] * (n + 1)
dp[2] = min(a[0], c + b[0])
lift = 0
if a[0] > c + b[0]: lift = 1
for i in range(3, n + 1):
    if lift:
        if a[i - 2] > b[i - 2]: dp[i] = dp[i - 1] + b[i - 2]
        else:
            dp[i] = dp[i - 1] + a[i - 2]
            lift = 0
    else:
        if a[i - 2] > b[i - 2]:
            dp[i] = dp[i - 1] + c + b[i - 2]
            lift = 1
        else: dp[i] = dp[i - 1] + a[i - 2]
for i in range(1, n + 1): print(dp[i], end = " ")


import math

n,c=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
dp=[[0,c]for x in range(n)]
dp[0]=[0,c]
for i in range(1,n):
	dp[i][0]=min(dp[i-1][0]+a[i-1],dp[i-1][1]+a[i-1])
	dp[i][1]=min(dp[i-1][0]+c+b[i-1],dp[i-1][1]+b[i-1])
print(' '.join([str(min(x)) for x in dp]))


import sys
n,c=map(int,sys.stdin.readline().split())
a=list(map(int,sys.stdin.readline().split()))
b=list(map(int,sys.stdin.readline().split()))
s,l=[0],[0]
s.append(a[0])
l.append(b[0]+c)
for i in range(2,n):
    st=min(s[-1]+a[i-1],l[-1]+a[i-1])
    lt=min(s[-1]+b[i-1]+c,l[-1]+b[i-1])
    s.append(st)
    l.append(lt)
ans=[]
for i in range(n):
    ans.append(min(s[i],l[i]))
print(" ".join(map(str, ans)))


import sys

input = sys.stdin.readline
out = sys.stdout

def main():
    n, c = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    dp = [0, min(a[0], c + b[0])] + [0]*(n - 2)
    elev = [True if a[0] >= c + b[0] else False] + [False]*n
    for i in range(2, n):
        if elev[i - 2]:
            if b[i - 1] <= a[i - 1]:
                dp[i] = dp[i - 1] + b[i - 1]
                elev[i - 1] = True
            else:
                dp[i] = dp[i - 1] + a[i - 1]
        else:
            if c + b[i - 1] <= a[i - 1]:
                dp[i] = dp[i - 1] + b[i - 1] + c
                elev[i - 1] = True
            else:
                dp[i] = dp[i - 1] + a[i - 1]
    print(*dp)

if __name__=="__main__":
   main()


import sys

input = sys.stdin.readline
out = sys.stdout

def main():
    n, c = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    dp = [0, min(a[0], c + b[0])] + [0]*(n - 2)
    elev = [False, True if a[0] >= c + b[0] else False] + [False]*(n - 1)
    for i in range(2, n):
        if elev[i - 1]:
            if b[i - 1] <= a[i - 1]:
                dp[i] = dp[i - 1] + b[i - 1]
                elev[i] = True
            else:
                dp[i] = dp[i - 1] + a[i - 1]
        else:
            if c + b[i - 1] <= a[i - 1]:
                dp[i] = dp[i - 1] + b[i - 1] + c
                elev[i] = True
            else:
                dp[i] = dp[i - 1] + a[i - 1]
    print(*dp)

if __name__=="__main__":
   main()


import sys

input = sys.stdin.readline
out = sys.stdout

def main():
    n, c = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    dp = [0, min(a[0], c + b[0])] + [0]*(n - 2)
    elev = [False, True if a[0] < c + b[0] else False] + [False]*(n - 1)
    for i in range(2, n):
        if elev[i - 1]:
            if b[i - 1] <= a[i - 1]:
                dp[i] = dp[i - 1] + b[i - 1]
                elev[i] = True
            else:
                dp[i] = dp[i - 1] + a[i - 1]
        else:
            if c + b[i - 1] <= a[i - 1]:
                dp[i] = dp[i - 1] + b[i - 1] + c
                elev[i] = True
            else:
                dp[i] = dp[i - 1] + a[i - 1]
    print(*dp)

if __name__=="__main__":
   main()


import sys

input = sys.stdin.readline
out = sys.stdout

inf = 10 ** 18

def main():
    n, c = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    dp_el = [c] + [inf] * n
    dp_lad = [0] + [inf] * n
    for i in range(1, n):
        dp_el[i] = min(dp_el[i], dp_lad[i - 1] + b[i - 1] + c, dp_el[i - 1] + b[i - 1])
        dp_lad[i] = min(dp_lad[i], dp_lad[i - 1] + a[i - 1], dp_el[i - 1] + a[i - 1])
    for i in range(n):
        print(min(dp_el[i], dp_lad[i]), end=" ")

if __name__ == "__main__":
    main()