#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

//int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);


void merge(long long a1[],long long len_a1,long long a2[],long long len_a2,long long a[]){
    long long i = 0,j = 0;
    while(i<len_a1 || j<len_a2){
        if(j>=len_a2 || (i<len_a1 && a1[i]<a2[j])){
            a[i+j] = a1[i];
            i++;
        }else{
            a[i+j] = a2[j];
            j++;
        }
    }
}
void mergeSort(long long a[],long long len_a){
    if(len_a > 1){
        long long m = len_a/2;
        long long n = len_a - m;
        long long a1[m];
        long long a2[n];
        for(long long i = 0;i < m;i++) a1[i] = a[i];
        for(long long i = 0;i < n;i++) a2[i] = a[m+i];
        mergeSort(a1,m);
        mergeSort(a2,n);
        merge(a1,m,a2,n,a);
    }
}
 
//////////////////////////////////////////


int N,K;
char S[100010];

int main(){
    scanf("%d%d",&N,&K);
    scanf("%s",S);
    
    int Sec[N][2];//1つ目は何連続か、二つ目は０か１か

    for(int i = 0;i < N;i++){
        Sec[i][0] = 1;
    }

    char mark = S[0];
    Sec[0][1] = S[0] - '0';
    Sec[0][0] = 0;
    int j = 0;

    if(Sec[0][1] == 0){
        Sec[0][1] = 1;
        Sec[1][0] = 0;
        j++;
    }

    for(int i = 0;i < N;i++){
        if(mark == S[i]){
            Sec[j][0]++;
        }else{
            mark = S[i];
            j++;
            Sec[j][1] = S[i] - '0';
        }
    }
    if(Sec[j][1] == 0){
        j++;
        Sec[j][1] = 1;
        Sec[j][0] = 0;
    }
    for(int i = j+1;i < N;i++){
        Sec[i][0] = 0;
    }
    //////////////////
    /*
    for(int i = 0;i <= j;i++){
        printf("%d",Sec[i][1]);
    }
    printf("\n");
    for(int i = 0;i <= j;i++){
        printf("%d",Sec[i][0]);
    }
    printf("\n");

    printf("j = %d\n",j);
    */
    ///////////////

    if(K >= j/2){
        printf("%d\n",N);
        return 0;
    }

    int count[j+2];
    count[0] = 0;

    //printf("0");
    for(int i = 1;i <= j;i++){
        count[i] = count[i-1] + Sec[i][0];
        //printf("%d",count[i]);
    }
    //printf("\n");
    int n = j/2 - K;
    int C[j/2 - K];
    int M = 0;
    //printf("%d\n",n);
    int count2[j+3];
    count2[0] = 0;
    for(int i = 1;i < j+2;i++){
        count2[i] = count[i-1];
    }
    for(int i = 0;i <= n;i++){
        C[i] = count2[(i+K)*2 + 1] - count2[i*2];
        //printf("%d = %d - %d\n",(i+K)*2 + 1,count2[(i+K)*2 + 1],count2[i*2]);
        if(M < C[i])M = C[i];
    }

    printf("%d\n",M);

    return 0;
}



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


Measured memory_bytes: 2048