n, k = gets.chomp.split(/\s/).map{|i| i.to_i}
s = gets.chomp

chunks = []
last = '1'
len = 0
s.each_char do |c|
  if c == last
    len += 1
  else
    chunks.push(len)
    len = 1
  end

  last = c
end
chunks.push(len)
chunks.push(0) if last == '0'
chunks.push(0)
chunks.push(0)

def search(arr)
    i = 0
    max_i = 0
    max = 0
    while i < (arr.size - 2)
    len = arr[i] + arr[i + 1] + arr[i + 2]
    if len > max
        max = len
        max_i = i
    end
    i += 2
    end

    [max, max_i]
end

def next_ary(arr, max, max_i)
    ret = []
    arr.each_with_index do |v, i|
        if i == max_i
            ret.push max
        elsif i == (max_i + 1) or i == max_i + 2
            #Do Nothing
        else
            ret.push v
        end
    end

    ret
end

max = 0
max_i = 0
k.times do |n|
    chunks = next_ary(chunks, max, max_i) if max > 0

    max, max_i = search(chunks)
end

print max



