##templete
n, k = gets.chomp.split(" ").map { |e|  e.to_i }
s = gets.chomp
lst = []
str = s[0]
count = 0
for i in 0..n-1 do
    if str == s[i]
        count += 1
    else
      lst.push(count)
      str = s[i]
      count = 1
    end
end
lst.push(count)
# print lst
leng = lst.length

if leng < 2 * k
  puts n
  exit 0
end



if s[0] == "1"
  if leng - 1 < 2 * k
    puts n
    exit 0
  end

  sum = 0
  for i in 0..2*k do
    sum += lst[i]
  end

  preindex1 = 0
  preindex2 = 1
  ans = sum

  for i in 2*k+1..leng-1 do
    if s[i] == "0"
      sum = sum - lst[preindex1] - lst[preindex2] + lst[i]
      preindex1 += 1
      preindex2 += 2
      if i+1 <= leng-1
        sum = sum + lst[i+1]
      end
      ans = ans > sum ? ans : sum
    end
  end
end



if s[0] == "0"
  if leng < 2 * k
    puts n
    exit 0
  end

  sum = 0
  for i in 0..2*k-1 do
    sum += lst[i]
  end

  preindex1 = 0
  preindex2 = 1
  ans = sum

  for i in 2*k..leng-1 do
    if s[i] == "0"
      sum = sum - lst[preindex1] - lst[preindex2] + lst[i]
      preindex1 += 1
      preindex2 += 2
      if i+1 <= leng-1
        sum = sum + lst[i+1]
      end
      ans = ans > sum ? ans : sum
    end
  end
end



print ans
