#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

template<int MOD> struct Fp {  
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

mint Combination(ll n, ll k){
    k = min(k , n-k);
    mint ret = 1;
    mint div = 1;
    for(int i = 0; i < k; i++){
        ret *= (n - i);
        div *= (k - i);
    }
    ret /= div;
    return ret;
}

signed main(){
	//cout << fixed << setprecision(10);
    int n,k; cin >> n >> k;
	string s; cin >> s;
    vector<pi> vec(0);
    int f = (s[0] == '0' ? 1 : 0);
    int cnt = 0;
    rep(i,0,n){
        int g = (s[i] == '0' ? 1 : 0);
        if(f != g){
            vec.push_back(make_pair(cnt , f));
            f = g;
            cnt = 0;
        }
        cnt++;
    }
    if(cnt != 0)vec.push_back(make_pair(cnt , f));
    int ans = 0;
    int memo = 0;
    int ind = 0;
    cnt = 0;
    if(vec.size() == 1){
        cout << n << endl;
        return 0;
    }
    /*if(vec[0].second == 1){
        vec.insert(vec.begin() , pl(0,0));
    }*/
    rep(i,0,vec.size()){
        cnt += vec[i].second;
        while(cnt > k){
            cnt -= vec[ind].second;
            memo -= vec[ind].first;
            ind++;
        }
        memo += vec[i].first;
        chmax(ans , memo);
    }
    chmax(ans , memo);
    cout << ans << endl;


	return 0;
}

Measured memory_bytes: 4448