n, k = list(map(int, input().split()))

s = eval(input())

s = list(map(int, s))



v = []

cnt = 1

for i in range(n - 1):

	if s[i] == s[i + 1]:

		cnt = cnt + 1

	else:

		v.append(cnt)

		cnt = 1

v.append(cnt)

m = len(v)



sum = [0] * (m + 1)

for i in range(1, m + 1):

	sum[i] = sum[i - 1] + v[i - 1]



ans = 0

for i in range(m + 1):

	if s[0] == 0:

		if i % 2 == 0:

			ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])

		else:

			ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])

	else:

		if i % 2 == 0:

			ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])

		else:

			ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])



k = k - 1

for i in range(m + 1):

	if s[0] == 0:

		if i % 2 == 1:

			ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])

		else:

			ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])

	else:

		if i % 2 == 1:

			ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])

		else:

			ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])



print(ans)
n, k = list(map(int, input().split()))

s = eval(input())

s = list(map(int, s))



v = []

cnt = 1

for i in range(n - 1):

	if s[i] == s[i + 1]:

		cnt = cnt + 1

	else:

		v.append(cnt)

		cnt = 1

v.append(cnt)

m = len(v)



sum = [0] * (m + 1)

for i in range(1, m + 1):

	sum[i] = sum[i - 1] + v[i - 1]



ans = 0

for i in range(m + 1):

	if s[0] == 0:

		if i % 2 == 0:

			ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])

		else:

			ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])

	else:

		if i % 2 == 0:

			ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])

		else:

			ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])



print(ans)

n, k = list(map(int, input().split()))
s = eval(input())
s = list(map(int, s))
v = []
cnt = 1
for i in range(n - 1):
    if s[i] == s[i + 1]:
        cnt = cnt + 1
    else:
        v.append(cnt)
        cnt = 1
v.append(cnt)
m = len(v)
sum = [0] * (m + 1)
for i in range(1, m + 1):
    sum[i] = sum[i - 1] + v[i - 1]
ans = 0
for i in range(m + 1):
    if s[0] == 0:
        if i % 2 == 0:
            ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
        else:
            ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
    else:
        if i % 2 == 0:
            ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
        else:
            ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
k = k - 1
for i in range(m + 1):
    if s[0] == 0:
        if i % 2 == 1:
            ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
        else:
            ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
    else:
        if i % 2 == 1:
            ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
        else:
            ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
print(ans)

n, k = list(map(int, input().split()))
s = eval(input())
s = list(map(int, s))
v = []
cnt = 1
for i in range(n - 1):
    if s[i] == s[i + 1]:
        cnt = cnt + 1
    else:
        v.append(cnt)
        cnt = 1
v.append(cnt)
m = len(v)
sum = [0] * (m + 1)
for i in range(1, m + 1):
    sum[i] = sum[i - 1] + v[i - 1]
ans = 0
for i in range(m + 1):
    if s[0] == 0:
        if i % 2 == 0:
            ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
        else:
            ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
    else:
        if i % 2 == 0:
            ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
        else:
            ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
print(ans)

-k = k - 1 -for i in range(m + 1): -    if s[0] == 0: -        if i % 2 == 1: -            ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)]) -        else: -            ans = max(ans, sum[i] - sum[max(i - k * 2, 0)]) -    else: -        if i % 2 == 1: -            ans = max(ans, sum[i] - sum[max(i - k * 2, 0)]) -        else: -            ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])