function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var K = parseInt(input[0].split(" ")[1]);
  var S = input[1].split("").map(x=>~~x);

  var S_arr = [];
  var j=0;
  S_arr[0] = [S[0]];
  for(var i=1; i < N; i++){
    if(S[i]==S[i-1]){
      S_arr[j].push(S[i]);
    }else{
      S_arr.push([S[i]]);
      j++;
    }
  }

  for(var k=0; k < K; k++){
    max = 0;
    max_i =0;

    for(var i=0; i < S_arr.length; i++){
      if(S_arr[i][0] == 0){
        if(i == 0){
          if(max < S_arr[i].length+S_arr[i+1].length){
            max=S_arr[i].length+S_arr[i+1].length;
            max_i=i;
          }
        }else if(i == S_arr.length-1){
          if(max < S_arr[i-1].length+S_arr[i].length){
            max=S_arr[i-1].length+S_arr[i].length;
            max_i=i;
          }
        }else{
          if( max < S_arr[i-1].length+S_arr[i].length+S_arr[i+1].length){
            max=S_arr[i-1].length+S_arr[i].length+S_arr[i+1].length;
            max_i=i;
          }
        }
      }
    }
    S_arr[max_i]=S_arr[max_i].map(x => 1);
    if(max_i == 0){
      S_arr[max_i]=S_arr[max_i].concat(S_arr[max_i+1]);
      S_arr.splice(max_i+1,max_i+1);
    }else if(max_i == S_arr.length-1){
      S_arr[max_i-1]=S_arr[max_i-1].concat(S_arr[max_i]);
      S_arr.splice(max_i,max_i);
    }else{
      S_arr[max_i-1]=S_arr[max_i-1].concat(S_arr[max_i].concat(S_arr[max_i+1]));
      S_arr.splice(max_i,max_i+1);
    }
  }
  var maxLength=0;
  for(var l=0; l < S_arr.length; l++){
    if(maxLength < S_arr[l].length) maxLength = S_arr[l].length;
  }
  console.log(maxLength);
}

var input=Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// var input=`14 2
// 11101010110011`
// Main(input);
