n, k = gets.split(' ').map{|a|a.to_i}
s = gets.to_s.chomp

# que に "0が連続する数", "1が連続する数" を格納
list_01 = []
counter = ''
s.chars.each do | c |
  if counter == ''
    counter = c
    next
  end
  if counter[0] == c
    counter = counter + c
  else
    
    list_01 << {s: counter.size, f: counter[0].to_i}
    counter = c
  end
end
list_01 << {s: counter.size, f: counter[0].to_i} if counter.size > 0

max = 0
0.upto(list_01.size-1) do | ind |
  sum = 0
  if list_01[ind][:f] == 0
    st = ind
    st -= 1 if ind > 0
    en = 2*k
    nums = list_01.slice(st, en)
    nums.each{|num| sum += num[:s]}
  else # == 1
    en = 2*k+1
    nums = list_01.slice(ind, en)
    nums.each{|num| sum += num[:s]}
  end
  max = sum if sum > max
end
p max