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

xss = []
s.split('').each do |x|
  if xss.empty?
    xss.push([x])
  else
    if xss.last[0] == x
      xss.last.push(x)
    else
      xss.push([x])
    end
  end
end

# p xss

def sum(xss)
  xss.map(&:size).reduce(0) { |acc, x| acc + x }
end

ans = 0
prev_sum = nil
prev_yss = nil
xss.each_with_index do |xs, i|
  next if i != 0 && xs[0] == '0'
  count = xs[0] == '0' ? 2 * k : 2 * k + 1
  yss = xss.slice(i, count)

  # p yss

  sum = nil
  if prev_sum
    prev_chunk = prev_yss[0][0] == '0' ? prev_yss.slice(0, 1) : prev_yss.slice(0, 2)
    current_chunk = yss[-1][0] == '0' ? yss.slice(-1, 1) : yss.slice(-2, 2)
    sum = prev_sum - sum(prev_chunk) + sum(current_chunk)
    # p "minus: #{prev_chunk}"
    # p "plus: #{current_chunk}"
    # p sum
  else
    sum = sum(yss)
    # p [sum]
  end
  # p yss
  ans = [ans, sum].max

  prev_sum = sum
  prev_yss = yss
  # p '-'
  break if i + count >= xss.size
end

puts ans
