N, K = gets.split.map(&:to_i)
S = gets.chomp

s01 = []

before_c = nil
sp = -1
count0 = 0
S.each_char do |c|
  if c != before_c
    sp += 1
    s01[sp] = {type: c, count: 0}
    before_c = c
    count0 += 1 if c == '0'
  end
  s01[sp][:count] += 1
end

s01.unshift({type: '1', count: 0}) if S[0] == '0'
s01 << {type: '1', count: 0} if S[-1] == '0'

k = [K, count0].min

s01_sum = [s01[0][:count]]

1.upto(s01.size - 1) do |i|
  s01_sum << s01_sum[i-1] + s01[i][:count]
end

l_max = s01.size - k - 2 - 1
if l_max < 0
  puts S.size
  exit
end

max = 0
0.upto(s01.size - k - 2 - 1) do |l|
  next if l.odd?
  r = l + k * 2
  sum = s01_sum[r] - (l > 0 ? s01_sum[l - 1] : 0)
  # p [l, r, sum, max]
  if sum > max
    max = sum
  end
end

puts max