n, k = gets.split(' ').map(&:to_i)
s = gets.chomp

data = []
s.each_char do |c|
  if c == '0'
    if data.empty? or data[-1] > 0
      data.push(-1)
    else
      data[-1] -= 1
    end
  else
    if data.empty? or data[-1] < 0
      data.push(1)
    else
      data[-1] += 1
    end
  end
end

i = data[0] < 0 ? 1 : 0
m = data.length/2 + i
if k >= m
  puts n
else
  data.map!(&:abs)
  j = 0
  l = k*2 + 1 - i
  sum = data[j, l].inject(:+)
  max = sum
  while l < data.length
    unless i == 1 and j == 0
      sum -= data[j]
      j += 1
    end
    sum -= data[j]
    j += 1
    sum += data[l,2].inject(:+)
    l += 2
    max = sum if sum > max
  end
  puts max
end
