#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
    int N, K;
    cin>>N>>K;
    string S;
    cin>>S;
    vector<int>onearr, zeroarr;
    int i=0;
    int tmp;
    while(i<S.size()){
        tmp = 0;
        if(S[i]=='0'){
            while(i<S.size() & S[i]=='0'){
                tmp++;
                i++;
            }
            zeroarr.push_back(tmp);
        }
        else {
            while(i<S.size() & S[i] == '1'){
                tmp++;
                i++;
            }
            onearr.push_back(tmp);
        }
    }
    /**
    for(int i=0;i<zeroarr.size();++i){
        cout<<zeroarr[i]<<endl;
    }
    cout<<"yey"<<endl;
    for(int i=0;i<onearr.size();++i){
        cout<<onearr[i]<<endl;
    }
    **/
    if(zeroarr.size() <= K){
        cout<<N<<endl;
    }
    else {
        int ans = 0;
        int tmpans;
        if(S[0]=='1'){
            for(int i=0;i<K;++i){
                ans += onearr[i];
                ans += zeroarr[i];
            }
            ans += onearr[K];
            tmpans = ans;
            if(S[S.size()-1]=='1'){
                //cout<<tmpans<<endl;
                for(int i=K;i<zeroarr.size();++i){
                    tmpans = tmpans - onearr[i-K] - zeroarr[i-K] + onearr[i+1] + zeroarr[i];
                    if(ans < tmpans)ans = tmpans;
                    //cout<<tmpans<<endl;
                }
            }
            else {
                //cout<<tmpans<<endl;
                for(int i=K;i<zeroarr.size()-1;++i){
                    tmpans = tmpans - onearr[i-K] - zeroarr[i-K] + onearr[i+1] + zeroarr[i];
                    if(ans < tmpans)ans=tmpans;
                    //cout<<tmpans<<endl;
                }
                tmpans = tmpans - onearr[zeroarr.size()-1-K] - zeroarr[zeroarr.size()-1-K] + zeroarr[zeroarr.size()-1];
                if(ans < tmpans)ans = tmpans;
                //cout<<tmpans<<endl;
            }
        }
        else {
            for(int i=0;i<K;++i){
                ans += zeroarr[i];
                ans += onearr[i];
            }
            tmpans = ans;
            if(S[S.size()-1]=='1'){
                //cout<<tmpans<<endl;
                for(int i=K;i<zeroarr.size();++i){
                    if(i==K){
                        tmpans = tmpans - zeroarr[i-K] + zeroarr[i] + onearr[i];
                    }
                    else {
                        tmpans = tmpans - zeroarr[i-K] - onearr[i-K-1] + zeroarr[i] + onearr[i];
                    }
                    if(ans < tmpans) ans = tmpans;
                    //cout<<tmpans<<endl;
                }
            }
            else{
                //cout<<tmpans<<endl;
                for(int i=K;i<zeroarr.size()-1;++i){
                    if(i==K){
                        tmpans = tmpans - zeroarr[i-K] + zeroarr[i] + onearr[i];
                    }
                    else{
                        tmpans = tmpans - zeroarr[i-K] - onearr[i-K-1] + zeroarr[i] + onearr[i];
                    }
                    if(ans < tmpans)ans = tmpans;
                    //cout<<tmpans<<endl;
                }
                tmpans = tmpans - zeroarr[zeroarr.size()-1-K] - onearr[zeroarr.size()-1-K-1] + zeroarr[zeroarr.size()-1];
                if(ans < tmpans)ans = tmpans;
                //cout<<tmpans<<endl;
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1020