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

# compress
a = Array.new(n, 0)
first = true
nn = 0
for i in 0...n
    if first || s[i] == s[i-1]
        first = false
    else
        nn = nn + 1
    end
    a[nn] = a[nn] + (s[i] == "0" ? -1 : 1)
end
nn = nn + 1

#
ans = 0
for i in 0...nn
    tmp = 0
    j = i
    cnt = 0
    while j < nn
        if a[j] < 0
            if cnt == k
                break
            end
            cnt += 1
            tmp -= a[j]
        else
            tmp += a[j]
        end
        j += 1
    end
    ans = [ans, tmp].max
end

puts ans