# coding: utf-8

# Your code here!

N, K = [int(_) for _ in input().split()]

S = str(eval(input()))



Nums = []

now, cnt = 1, 0

for i in range(N):

    if S[i] == str(now): cnt += 1

    else:

        Nums.append(cnt)

        now = 1 - now

        cnt = 1

if cnt != 0: Nums.append(cnt)

if len(Nums) % 2 == 0: Nums.append(0)





# add = 2 * K + 1

# ans = 0

# for i in range(0, len(Nums), 2):

#     tmp = 0

#     left = i

#     right = min(i+add, len(Nums))

#     j = left

#     while j < right:

#         tmp += Nums[j]

#         j += 1

#     ans = max(tmp, ans)

# print(ans)



#------------------------

add = 2 * K + 1

ans = 0

left = 0

right = 0

tmp = 0

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

    nextLeft = i 

    nextRight = min(i + add, len(Nums))

    while nextLeft > left:

        tmp -= Nums[left]

        left += 1

    while nextRight > right:

        tmp += Nums[right]

        right += 1

    #print('left, right:   ', left, right)

    ans = max(tmp, ans)

        

print(ans)

# coding: utf-8

# Your code here!

N, K = [int(_) for _ in input().split()]

S = str(eval(input()))



Nums = []

now, cnt = 1, 0

for i in range(N):

    if S[i] == str(now): cnt += 1

    else:

        Nums.append(cnt)

        now = 1 - now

        cnt = 1

if cnt != 0: Nums.append(cnt)

if len(Nums) % 2 == 0: Nums.append(0)





# add = 2 * K + 1

# ans = 0

# for i in range(0, len(Nums), 2):

#     tmp = 0

#     left = i

#     right = min(i+add, len(Nums))

#     j = left

#     while j < right:

#         tmp += Nums[j]

#         j += 1

#     ans = max(tmp, ans)

# print(ans)



#------------------------

# add = 2 * K + 1

# ans = 0

# left = 0

# right = 0

# tmp = 0

# for i in range(0, len(Nums), 2):

#     nextLeft = i 

#     nextRight = min(i + add, len(Nums))

#     while nextLeft > left:

#         tmp -= Nums[left]

#         left += 1

#     while nextRight > right:

#         tmp += Nums[right]

#         right += 1

#     #print('left, right:   ', left, right)

#     ans = max(tmp, ans)

        

# print(ans)

#------------------------

#print(Nums)

add = 2 * K + 1

sums = [0 for _ in range(len(Nums) + 1)]

for i in range(len(Nums)):

    sums[i+1] = sums[i] + Nums[i]

#print(sums)



ans = 0

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

    left = i

    right = min(i+add, len(Nums))

    tmp = sums[right] - sums[left]

    ans = max(ans, tmp)

print(ans)
# coding: utf-8
# Your code here!
N, K = [int(_) for _ in input().split()]
S = str(eval(input()))
Nums = []
now, cnt = 1, 0
for i in range(N):
    if S[i] == str(now):
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    Nums.append(cnt)
if len(Nums) % 2 == 0:
    Nums.append(0)
# add = 2 * K + 1
# ans = 0
# for i in range(0, len(Nums), 2):
#     tmp = 0
#     left = i
#     right = min(i+add, len(Nums))
#     j = left
#     while j < right:
#         tmp += Nums[j]
#         j += 1
#     ans = max(tmp, ans)
# print(ans)
# ------------------------
add = 2 * K + 1
ans = 0
left = 0
right = 0
tmp = 0
for i in range(0, len(Nums), 2):
    nextLeft = i
    nextRight = min(i + add, len(Nums))
    while nextLeft > left:
        tmp -= Nums[left]
        left += 1
    while nextRight > right:
        tmp += Nums[right]
        right += 1
    # print('left, right:   ', left, right)
    ans = max(tmp, ans)
print(ans)

# coding: utf-8
# Your code here!
N, K = [int(_) for _ in input().split()]
S = str(eval(input()))
Nums = []
now, cnt = 1, 0
for i in range(N):
    if S[i] == str(now):
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    Nums.append(cnt)
if len(Nums) % 2 == 0:
    Nums.append(0)
# add = 2 * K + 1
# ans = 0
# for i in range(0, len(Nums), 2):
#     tmp = 0
#     left = i
#     right = min(i+add, len(Nums))
#     j = left
#     while j < right:
#         tmp += Nums[j]
#         j += 1
#     ans = max(tmp, ans)
# print(ans)
# ------------------------
# add = 2 * K + 1
# ans = 0
# left = 0
# right = 0
# tmp = 0
# for i in range(0, len(Nums), 2):
#     nextLeft = i
#     nextRight = min(i + add, len(Nums))
#     while nextLeft > left:
#         tmp -= Nums[left]
#         left += 1
#     while nextRight > right:
#         tmp += Nums[right]
#         right += 1
#     #print('left, right:   ', left, right)
#     ans = max(tmp, ans)
# print(ans)
# ------------------------
# print(Nums)
add = 2 * K + 1
sums = [0 for _ in range(len(Nums) + 1)]
for i in range(len(Nums)):
    sums[i + 1] = sums[i] + Nums[i]
# print(sums)
ans = 0
for i in range(0, len(Nums), 2):
    left = i
    right = min(i + add, len(Nums))
    tmp = sums[right] - sums[left]
    ans = max(ans, tmp)
print(ans)

+# add = 2 * K + 1 +# ans = 0 +# left = 0 +# right = 0 +# tmp = 0 +# for i in range(0, len(Nums), 2): +#     nextLeft = i +#     nextRight = min(i + add, len(Nums)) +#     while nextLeft > left: +#         tmp -= Nums[left] +#         left += 1 +#     while nextRight > right: +#         tmp += Nums[right] +#         right += 1 +#     #print('left, right:   ', left, right) +#     ans = max(tmp, ans) +# print(ans) +# print(Nums) +sums = [0 for _ in range(len(Nums) + 1)] +for i in range(len(Nums)): +    sums[i + 1] = sums[i] + Nums[i] +# print(sums) -left = 0 -right = 0 -tmp = 0 -    nextLeft = i -    nextRight = min(i + add, len(Nums)) -    while nextLeft > left: -        tmp -= Nums[left] -        left += 1 -    while nextRight > right: -        tmp += Nums[right] -        right += 1 -    # print('left, right:   ', left, right) -    ans = max(tmp, ans) +    left = i +    right = min(i + add, len(Nums)) +    tmp = sums[right] - sums[left] +    ans = max(ans, tmp)