#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////

/*（๑•﹏•๑｀) */

int main() {
    int N,K;
    string S;
    cin >> N >> K;
    cin >> S;

    int count;

    vector<int> U;

    if (S[0] == '0') U.PB(0);

    count = 1;
    REP(i,S.size()-1){
        if (S[i] == S[i+1]){
            count++;
        }else{
            if (S[i] == '1') U.PB(count);
            count = 1;
        }
    }

    if (S[N-1] == '1') U.PB(count);

    vector<int> V;
    count = 1;
    REP(i,S.size()-1){
        if (S[i] == S[i+1]){
            count++;
        }else{
            if (S[i] == '0') V.PB(count);
            count = 1;
        }
    }

    if (S[N-1] == '0') V.PB(count);

    int start;
    if (S[0] == '0') start = 0;
    else start = 1;

    int Usize = U.size();
    int Vsize = V.size();

    if (Vsize <= K){
        int ans = 0;
        REP(i,Usize){
            ans += U[i];
        }

        REP(j,Vsize){
            ans += V[j];
        }
        cout << ans << "\n";
        return 0;
    }

    int ans = 0;

    vector<int> Us;
    vector<int> Vs;
    Us.PB(0);
    Vs.PB(0);
    int lastu;
    int lastv;
    REP(i,Usize){
        Us.PB(Us[i] + U[i]);
        lastu = Us[i] + U[i];
    }

    REP(i,Vsize){
        Vs.PB(Vs[i] + V[i]);
        lastv = Vs[i] + V[i];
    }

    REP(i,K){
        Us.PB(lastu);
        Vs.PB(lastv);
    }


    FORq(i,1,Vsize-K+1){
        int nans = Vs[i+K-1] -Vs[i-1] + Us[i+K-1 + 1] - Us[i-1];
        chmax(ans,nans);
    }

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


Measured memory_bytes: 1724