N, K = gets.split.map(&:to_i)
S = gets.chomp.split('').map(&:to_i) + [-1]

bs = []
len = 0
(N+1).times do |i|
    if i==0 || S[i] == S[i-1]
        len += 1
    else
        bs.push([S[i-1], len])
        len = 1
    end
end

ans = 0
sum = 0
rev = 0

que = []

bs.each do |bit, len|
    sum += len
    que.push([bit, len])
    rev += 1 if bit == 0
    while rev > K
        b, l = que.shift
        rev -= 1 if b == 0
        sum -= l
    end
    ans = sum if ans < sum
end
puts ans