#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct AccSum{
    vector<ll> Ac;
    ll L;
    AccSum(vector<ll> &A){
        L = A.size();
        Ac.resize(L+1);
        FOR(i, 0, L){
            Ac[i+1] = Ac[i] + A[i];
        }
    }

    // sum of [a, b]
    ll sum(ll a, ll b){
        if(a<0) return -1;
        if(b>L-1) return -1;
        return Ac[b+1] - Ac[a];
    }
};

// 0 black
// 1 white

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll N, K;
    cin >> N >> K;

    string s;
    cin >> s;
    ll L = s.size();

    // count 
    vector<ll> C;

    char current = s[0];
    ll count = 1;
    FOR(i, 1, L){
        char c = s[i];
        if(c==current){
            count++;
        }else{
            C.push_back(count);
            count = 1;
        }
        current = c;
    }
    C.push_back(count);

    // pn(s);
    // pn(C.size());
    // vprint(C);

    vector<ll> B;
    vector<ll> W;
    if(s[0]=='0'){
        FOR(i, 0, C.size()){
            ll c = C[i];
            if(i%2==0){
                B.push_back(c);
            }else{
                W.push_back(c);
            }
        }
    }else{
        FOR(i, 0, C.size()){
            ll c = C[i];
            if(i%2==1){ // !
                B.push_back(c);
            }else{
                W.push_back(c);
            }
        }
    }

    // pn(B.size());
    // vprint(B);
    // pn(W.size());
    // vprint(W);

    // 全員１にできる
    if(B.size()<=K){
        p(N);
        return 0;
    }

    // 以降、B.size()>K

    // 累積和
    auto AcB = AccSum(B);
    auto AcW = AccSum(W);

    bool is_head_white;
    if(s[0]=='0'){
        is_head_white = false;
    }else{
        is_head_white = true;
    }

    ll max_sum = 0;
    FOR(i, 0, B.size()-K+1){
        // i ~ i+K-1までの和
        // ll b_sum = AcB[i+K] - AcB[i];
        ll b_sum = AcB.sum(i, i+K-1);
        // pn(b_sum);

        if(is_head_white){
            // i ~ i+K-1までの和
            // ll w_sum = AcW[i+K] - AcW[i];
            ll w_sum = AcW.sum(i, i+K-1);

            if(i+K<W.size()){
                w_sum += W[i+K];
            }
            //pn(w_sum);
            ll sum = b_sum + w_sum;
            max_sum = max(max_sum, sum);
        }else{
            // i ~ i+K-2までの和
            // ll w_sum = AcW[i+K-1] - AcW[i];
            ll w_sum = AcW.sum(i, i+K-2);

            if(i+K-1<W.size()){
                w_sum += W[i+K-1];
            }
            if(i-1>=0){
                w_sum += W[i-1];
            }
            ll sum = b_sum + w_sum;
            max_sum = max(max_sum, sum);
        }
    }

    p(max_sum);
    
    return 0;
}


Measured memory_bytes: 3140