#include<bits/stdc++.h>
using namespace std;

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];
int pref[N+2]={0};
int sz_pref[N+2]={0};
int sz_suff[N+2]={0};
int nex[N+2];
int32_t  main(){
  IOS;
  int n,k;cin>>n>>k;
  string s;cin>>s;
  vii a;
  vi v;
  memset(pref,0,sizeof(pref));
  memset(nex,-1,sizeof(nex));
  for(int i=0;i<n;++i){
    if(i==0 && s[i]=='1')pref[i]=1;
    pref[i]=(s[i]=='1')+pref[i-1];
    if(v.size()==0)v.pb(i);
    else{
      if(s[i]==s[v.back()])continue;
      else{
        nex[v.back()]=i;
        v.pb(i);
      }
    }
  }
  bool flag=false;
  for(int i=0;i<n;++i){
    char it=s[i];
    if(it=='1'){flag=false;continue;}
    else{
      if(flag==false){
        a.pb({i,1});
      }else{
        if(a.size()==0){
          a.pb({i,1});
        }else{
          a[a.size()-1].ss+=1;
        }
      }
      flag=true;
    }
  }
  {
    vii b;
    bool flag=false;
    for(int i=0;i<n;++i){
      char it=s[i];
      if(it=='0'){flag=false;continue;}
      else{
        if(flag==false){
          b.pb({i,1});
        }else{
          if(a.size()==0){
            b.pb({i,1});
          }else{
            b[b.size()-1].ss+=1;
          }
        }
        flag=true;
      }
    }

    for(auto it:b)sz_pref[it.ff]+=it.ss;
    b.clear();
    flag=false;
    for(int i=n-1;i>=0;--i){
      char it=s[i];
      if(it=='0'){flag=false;continue;}
      else{
        if(flag==false){
          b.pb({i,1});
        }else{
          if(a.size()==0){
            b.pb({i,1});
          }else{
            b[b.size()-1].ss+=1;
          }
        }
        flag=true;
      }
    }

    //for(auto it:b)cout<<it.ff<<" "<<it.ss<<endl;
    for(auto it:b)sz_suff[it.ff]+=it.ss;
  }
  //now for all k adjacent things find the sum and 1's lying in between them 
  if(a.size()<=k){cout<<n<<endl;return 0;}
  //for every window of size k find it's sum 
  int sum=0;
  int ans=0;
  for(int i=0;i<k;++i){
    sum+=a[i].ss;
   // cout<<a[i].ff<<" "<<a[i].ss<<" i,a[i].ss\n";
  }

  int val=0;
  if(a[0].ff>0) { 
    val+=sz_suff[a[0].ff-1];
    //cout<<sz_suff[a[0].ff-1]<<"  suff\n";
  }
  //cout<<val<<" val\n";
  if(nex[a[k-1].ff]!=-1) { 
    int t=nex[a[k-1].ff];
    //cout<<t<<" t\n";
    val+=sz_pref[t];
    //cout<<sz_pref[t]<<" sz_pref\n";
  }
  //cout<<val<<" val \n";
 // cout<<sum<<" "<<val<<" sum,val"<<endl;
 /* for(int i=0;i<n;++i){
    if(i>=a[0].ff && i<=a[k-1].ff)val+=sz_pref[i];
  }*/
  val+=pref[a[k-1].ff]-pref[a[0].ff];
//  cout<<val<<" new val \n";

  ans=val+sum;
  for(int i=k;i<a.size();++i){
    sum+=a[i].ss;
    sum-=a[i-k].ss;
    val=0;
    val+=sz_suff[a[i-k+1].ff-1];
    int t=nex[a[i].ff];
    if(t!=-1)
    val+=sz_pref[t];
   /* for(int j=0;j<n;++j){
      if(j>=a[i-k+1].ff && j<=a[i].ff)val+=sz_pref[j];
    }*/
    val+=pref[a[i].ff]-pref[a[i-k+1].ff];
    ans=max(ans,val+sum);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3272