#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);

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

    vector<ll> B;
    vector<ll> W;

    if(is_head_white){
        FOR(i, 0, C.size()){
            ll c = C[i];
            if(i%2==0){
                W.push_back(c);
            }else{
                B.push_back(c);
            }
        }
    }
    // 先頭が黒
    else{
        FOR(i, 0, C.size()){
            ll c = C[i];
            if(i%2==0){
                B.push_back(c);
            }else{
                W.push_back(c);
            }
        }
    }

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

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

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

    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);
        // pn(i);

        if(is_head_white){
            ll w_sum0 = AcW.sum(i, i+K-1);
            ll w_sum1 = AcW.sum(i, i+K);
            ll w_sum = max(w_sum0, w_sum1);
            // cout << w_sum0 << " " << w_sum1 << endl;

            ll sum = b_sum + w_sum;
            max_sum = max(max_sum, sum);
        }
        else{
            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