n, k = gets.split.map(&:to_i)
s = gets.chomp
# データ終了の目印を付加
s += "D"
hand_standing = []
standing = []

previous = ""
count = 1

hand_standing << 0 if s[0] == "0"

s.chars do |char|
  if previous == char
    count += 1
  else
    if previous == "0"
      standing << count
    elsif previous == "1"
      hand_standing << count
    end
    previous = char
    count = 1
  end
end

hand_standing << 0 if s[-2] == "0"

hand_standing_sum = []
(k + 1).times { hand_standing_sum.push(hand_standing.shift) unless hand_standing.empty? }
standing_sum = []
k.times { standing_sum.push(standing.shift) unless standing.empty? }
ans = hand_standing_sum.inject(0, :+) + standing_sum.inject(0, :+)

until hand_standing.empty?
  hand_standing_sum.shift
  hand_standing_sum.push(hand_standing.shift)
  standing_sum.shift
  standing_sum.push(standing.shift)
  sum = hand_standing_sum.inject(0, :+) + standing_sum.inject(0, :+)
  ans = sum if sum > ans
end

puts ans
