'use strict';

function Main(input) {
  const N = Number(input.split("\n")[0].split(" ")[0])
  const K = Number(input.split("\n")[0].split(" ")[1])
  const S = input.split("\n")[1].split("")
  
  for (let i=1; i<N; i++) {
    if (S[i] !== S[i-1].replace(",", "")) {
      S[i] = "," + S[i]
    }
  }

  const S2 = S.join("").split(",")

  const lenList = []
  for (let s of S2) {
    lenList.push({len: s.length, color: s.slice(0,1)})
  }

  // 一つしかない
  let max3 = 0
  if (lenList.length === 1) {
    max3 = lenList[0].len
  }

  // 1に合わせるタイプ
  let max1 = 0
  if (K === 1) {
    for (let n=0; n<lenList.length-1; n++) {
      let count = 0
      count += lenList[n].len
      count += lenList[n+1].len
      if (count > max1) {
        max1 = count
      }
    }
  } else {
    for (let j=0; j<lenList.length-(2*K); j++) {
      if (lenList[j].color === "0") {
        continue
      }
      let count = 0
      for (let k=0; k<(2*K+1); k++) {
        count += lenList[j+k].len
      }
      if (count > max1) {
        max1 = count
      }
    }
  }

  // 0に合わせて反転
  let max2 = 0
  if (K !== 1) {
    for (let l=0; l<lenList.length-(2*(K-1)); l++) {
      if (lenList[l].color === "1") {
        continue
      }
      let count = 0
      for (let m=0; m<(2*(K-1)+1); m++) {
        count += lenList[l+m].len
      }
      if (count > max2) {
        max2 = count
      }
    }  
  }

  console.log(Math.max(max1, max2, max3, 1))
};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
