def main():

	N, K = list(map(int, input().split()))

	S = eval(input())

	current = "1"

	current_len = 0

	nums = []

	for i in range(N):

		if S[i] != current:

			nums.append(current_len)

			current_len = 1

			current = S[i]

		else:

			current_len += 1



	nums.append(current_len)

	if len(nums) %2 == 0:

		nums.append(0)



	distance = 2*K+1

	ans = 0

	left, right = 0, 0

	tmp = 0

	for i in range(0, len(nums), 2):

		next_left = i

		next_right = min(i+distance, len(nums))

		# move left

		while next_left > left:

			tmp -= nums[left]

			left += 1

		# move right

		while next_right > right:

			tmp += nums[right]

			right += 1

		ans = max(tmp, ans)



	print(ans)





if __name__ == '__main__':

    main()
def main():

	N, K = list(map(int, input().split()))

	S = eval(input())

	current = "1"

	current_len = 0

	nums = []

	for i in range(N):

		if S[i] != current:

			nums.append(current_len)

			current_len = 1

			current = S[i]

		else:

			current_len += 1



	nums.append(current_len)

	if len(nums) %2 == 0:

		nums.append(0)



	distance = 2*K+1

	ans = 0

	sums = [0]*(len(nums)+1)

	for i in range(len(nums)):

		sums[i+1] = sums[i] + nums[i]



	for i in range(0, len(nums), 2):

		left = i

		right = min(i+distance, len(nums))

		tmp = sums[right] - sums[left]

		ans = max(tmp, ans)



	print(ans)





if __name__ == '__main__':

    main()
def main():
    N, K = list(map(int, input().split()))
    S = eval(input())
    current = "1"
    current_len = 0
    nums = []
    for i in range(N):
        if S[i] != current:
            nums.append(current_len)
            current_len = 1
            current = S[i]
        else:
            current_len += 1
    nums.append(current_len)
    if len(nums) % 2 == 0:
        nums.append(0)
    distance = 2 * K + 1
    ans = 0
    left, right = 0, 0
    tmp = 0
    for i in range(0, len(nums), 2):
        next_left = i
        next_right = min(i + distance, len(nums))
        # move left
        while next_left > left:
            tmp -= nums[left]
            left += 1
        # move right
        while next_right > right:
            tmp += nums[right]
            right += 1
        ans = max(tmp, ans)
    print(ans)


if __name__ == "__main__":
    main()

def main():
    N, K = list(map(int, input().split()))
    S = eval(input())
    current = "1"
    current_len = 0
    nums = []
    for i in range(N):
        if S[i] != current:
            nums.append(current_len)
            current_len = 1
            current = S[i]
        else:
            current_len += 1
    nums.append(current_len)
    if len(nums) % 2 == 0:
        nums.append(0)
    distance = 2 * K + 1
    ans = 0
    sums = [0] * (len(nums) + 1)
    for i in range(len(nums)):
        sums[i + 1] = sums[i] + nums[i]
    for i in range(0, len(nums), 2):
        left = i
        right = min(i + distance, len(nums))
        tmp = sums[right] - sums[left]
        ans = max(tmp, ans)
    print(ans)


if __name__ == "__main__":
    main()

-    left, right = 0, 0 -    tmp = 0 +    sums = [0] * (len(nums) + 1) +    for i in range(len(nums)): +        sums[i + 1] = sums[i] + nums[i] -        next_left = i -        next_right = min(i + distance, len(nums)) -        # move left -        while next_left > left: -            tmp -= nums[left] -            left += 1 -        # move right -        while next_right > right: -            tmp += nums[right] -            right += 1 +        left = i +        right = min(i + distance, len(nums)) +        tmp = sums[right] - sums[left]