#include <bits/stdc++.h>
#include <unistd.h>

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> num;
    if (s[0] == '0') num.push_back(0);
    int cnt_0 = 0, cnt_1 = 0, cnt = 0;
    rep(i, n) {
        if (s[i] == '0') {
            if (cnt_1 != 0) {
                num.push_back(cnt_1);
                cnt_1 = 0;
            }
            ++cnt_0;
            if (i == n - 1) {
                num.push_back(cnt_0);
                ++cnt;
            }
        } else {
            if (cnt_0 != 0) {
                num.push_back(cnt_0);
                ++cnt;
                cnt_0 = 0;
            }
            ++cnt_1;
            if (i == n - 1) num.push_back(cnt_1);
        }
    }
    if (cnt <= k) {
        cout << n << endl;
        return 0;
    }
    if (s[n - 1] == '0') num.push_back(0);
    vector<llong> cum(num.size() + 1);
    cum[0] = 0;
    rep(i, num.size()) {
        cum[i + 1] = cum[i] + num[i];
    }

    llong ans = -1;
        int left = 0, right = 2 * k + 1;
        while (right <= cum.size()) {
            ans = max(ans, cum[right] - cum[left]);
            left += 2;
            right += 2;
        }
        cout << ans << endl;
    /*
    if (s[0] != '0' && s[n - 1] != '0') {
        llong ans = -1;
        int left = 0, right = 2 * k + 1;
        while (right <= cum.size()) {
            ans = max(ans, cum[right] - cum[left]);
            left += 2;
            right += 2;
        }
        cout << ans << endl;
    } else if (s[0] == '0' && s[n - 1] != '0') {
        llong ans1 = -1;
        int left = 1, right = 2 * k + 2;
        while (right <= cum.size()) {
            ans1 = max(ans1, cum[right] - cum[left]);
            left += 2;
            right += 2;
        }

        llong ans2 = -1;
        left = 0, right = 2 * k;
        while (right <= cum.size()) {
            ans2 = max(ans2, cum[right] - cum[left]);
            left += 2;
            right += 2;
        }

        cout << max(ans1, ans2) << endl;
    } else if (s[0] != '0' && s[n - 1] == '0') {
        llong ans1 = -1;
        int left = 0, right = 2 * k + 1;
        while (right <= cum.size() + 2) {
            ans1 = max(ans1, cum[right] - cum[min(left, (int)cum.size()]);
            left += 2;
            right += 2;
        }

        llong ans2 = -1;
        left = 1, right = 2 * k + 1;
        while (right <= cum.size()) {
            ans2 = max(ans2, cum[right] - cum[left]);
            left += 2;
            right += 2;
        }

        cout << max(ans1, ans2) << endl;
    } else {
        llong ans1 = -1;
        int left = 0, right = 2 * k;
        while (right <= cum.size()) {
            ans1 = max(ans1, cum[right] - cum[left]);
            left += 2;
            right += 2;
        }

        llong ans2 = -1;
        left = 1, right = 2 * k + 2;
        while (right <= cum.size()) {
            ans2 = max(ans2, cum[right] - cum[left]);
            left += 2;
            right += 2;
        }

        cout << max(ans1, ans2) << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 1656