/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    int N,K;cin >> N >> K;
    string S;cin >> S;
    //圧縮させる 000111001101→332211にして、状態も圧縮する 000111001101→010101
    vector<bool> which01;
    vector<int> compress;
    int ren = 0,nowNum = -1;
    for(int i = 0;i<N;i++){
        if(i == 0){
            nowNum = S.at(i)-'0';
            ren = 1;
            if(i == N-1){
                compress.push_back(ren);
                which01.push_back(nowNum);
            }
            continue;
        }
        if(nowNum == S.at(i)-'0'){
            ren++;
        }
        else{
            which01.push_back(nowNum);
            compress.push_back(ren);
            ren = 1;
            nowNum = S.at(i)-'0';
        }
        if(i == N-1){
            compress.push_back(ren);
            which01.push_back(nowNum);
        }
    }
    /*for(int V : compress) cout << V << " ";
    cout << endl;
    for(int V : which01) cout << V << " ";
    cout << endl;*/
    int ans = 0;
    int instructionCount = 0;
    int score = 0;
    int deleteIndex = 0;
    for(int i = 0;i<compress.size();i++){
        if(which01.at(i) == 0) instructionCount++;
        if(instructionCount <= K){
            score += compress.at(i);
        }
        else{
            score += compress.at(i);
            //0の塊を左から一個消せるまで
            for(int j = deleteIndex;j<=deleteIndex+2;j++){
                //cout << score << endl;
                if(which01.at(j) == 0){
                    instructionCount--;
                    score -= compress.at(j);
                    deleteIndex++;
                    break;
                }
                else{
                    score -= compress.at(j);
                    deleteIndex++;
                }
            }
        }
        ans = max(ans,score);
        //cout << score << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3996