function Main(input) {
  var list = input.split("\n");
  var nk = list[0].split(" ");
  var N = nk[0];
  var K = nk[1];
  var L = 2*K+1;
  var S = list[1].split("");
  S.map( function(value){
    return parseInt(value);
  })
  
  var count, rev;
  var state = 0;
  var maxcount = 0;
  var Sarray = new Array(0);
  
  count = 0
  state = 1;
  
  for(i=0;i<N;i++){
    if(S[i] != state) {
      state = 1 - state;
      Sarray.push(count);
      count = 1;
    } else count++;
  }
  Sarray.push(count);
  if(Sarray.length == 1) Sarray.push(0);
  if(Sarray.length % 2 == 0) Sarray.push(0);
  
  var ans = 0;
  for(i=0;i<Math.min(Sarray.length,L);i++){
    ans += Sarray[i];
  }
  var tmp;
  var lasttmp = ans;
  var Sn = Sarray.length;
  
  while(Sarray.length > L) {
    tmp = lasttmp - (Sarray[0] + Sarray[1]) + (Sarray[L] + Sarray[L+1]);
    if (tmp > ans) ans = tmp;
    lasttmp = tmp;
    Sarray.shift();
    Sarray.shift();
  }
  console.log(ans);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));