

def 眠い():

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

	aS = [0]*N

	iS = 0

	iC = 0

	for s in eval(input()):

		if s == '0' :

			if iS % 2:

				aS[iS] = iC

				iS += 1

				iC = 1

			else:

				iC += 1

		else:

			if iS % 2:

				iC += 1

			else:

				aS[iS] = iC

				iS += 1

				iC = 1



	if iC:

		if s == '0' :

			if iS % 2:

				aS[iS]=0

				iS+=1

				aS[iS]=iC

			else:

				if len(aS) < iS +1 :

					aS.append(0)

					aS[iS]=iC

				else:

					aS[iS]=iC

		else:

			if iS % 2:

				if len(aS) < iS +1:

					aS.append(0)	

					aS[iS]=iC

				else:

					aS[iS]=iC

			else:

				aS[iS]=0

				iS +=1

				aS[iS]=iC

	aS=aS[:iS+1]

	iL = len(aS)

	iLP = iL // 2

	if iL % 2:

		iLP += 1

		if iLP <= K:

			print(N)

		else:

			iD = sum(aS[:2*K])

			iMax = iD

			for i in range(1,iLP -K+1):

				if i == 1:

					iD -= aS[0]

				else:

					j = (i-1)*2

					iD -= sum(aS[j-1:j+1])

				if i == iLP -K :

					iD += aS[-1]

				else:

					j = (i+K-1)*2

					iD +=  sum(aS[j:j+2])

				if iMax < iD:

					iMax = iD

			print(iMax)

	else:

		if iLP <= K:

			print(N)

		else:

			iD = sum(aS[:2*K])

			iMax = iD

			for i in range(1,iLP -K+1):

				if i == 1:

					iD -= aS[0]

				else:

					j = (i-1)*2

					iD -= sum(aS[j-1:j+1])

				j = (i+K-1)*2

				iD +=  sum(aS[j:j+2])

				if iMax < iD:

					iMax = iD

			print(iMax)



眠い()











#尺取を累積和にかえてみた

def 眠い():

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

	aS = [0]*N

	iS = 0

	iC = 0

	for s in eval(input()):

		if s == '0' :

			if iS % 2:

				aS[iS] = iC

				iS += 1

				iC = 1

			else:

				iC += 1

		else:

			if iS % 2:

				iC += 1

			else:

				aS[iS] = iC

				iS += 1

				iC = 1



	if iC:

		if s == '0' :

			if iS % 2:

				aS[iS]=0

				iS+=1

				aS[iS]=iC

			else:

				if len(aS) < iS +1 :

					aS.append(0)

					aS[iS]=iC

				else:

					aS[iS]=iC

		else:

			if iS % 2:

				if len(aS) < iS +1:

					aS.append(0)	

					aS[iS]=iC

				else:

					aS[iS]=iC

			else:

				aS[iS]=0

				iS +=1

				aS[iS]=iC

	aS=aS[:iS+1]

	iL = len(aS)

	accS = [0]*(iL+3)

	for i in range(iL):

		accS[i+1]=aS[i]+accS[i]

	accS[-2]=accS[-3]



	iLP=iL//2

	if iL % 2:

		iLP += 1

		if iLP <= K:

			print(N)

			exit()

	else:

		if iLP <= K:

			print(N)

			exit()

	print((max(accS[(i+K)*2]-accS[i*2 -1 ] for i in range(iLP-K+1))))



眠い()











def 眠い():
    N, K = [int(_) for _ in input().split()]
    aS = [0] * N
    iS = 0
    iC = 0
    for s in eval(input()):
        if s == "0":
            if iS % 2:
                aS[iS] = iC
                iS += 1
                iC = 1
            else:
                iC += 1
        else:
            if iS % 2:
                iC += 1
            else:
                aS[iS] = iC
                iS += 1
                iC = 1
    if iC:
        if s == "0":
            if iS % 2:
                aS[iS] = 0
                iS += 1
                aS[iS] = iC
            else:
                if len(aS) < iS + 1:
                    aS.append(0)
                    aS[iS] = iC
                else:
                    aS[iS] = iC
        else:
            if iS % 2:
                if len(aS) < iS + 1:
                    aS.append(0)
                    aS[iS] = iC
                else:
                    aS[iS] = iC
            else:
                aS[iS] = 0
                iS += 1
                aS[iS] = iC
    aS = aS[: iS + 1]
    iL = len(aS)
    iLP = iL // 2
    if iL % 2:
        iLP += 1
        if iLP <= K:
            print(N)
        else:
            iD = sum(aS[: 2 * K])
            iMax = iD
            for i in range(1, iLP - K + 1):
                if i == 1:
                    iD -= aS[0]
                else:
                    j = (i - 1) * 2
                    iD -= sum(aS[j - 1 : j + 1])
                if i == iLP - K:
                    iD += aS[-1]
                else:
                    j = (i + K - 1) * 2
                    iD += sum(aS[j : j + 2])
                if iMax < iD:
                    iMax = iD
            print(iMax)
    else:
        if iLP <= K:
            print(N)
        else:
            iD = sum(aS[: 2 * K])
            iMax = iD
            for i in range(1, iLP - K + 1):
                if i == 1:
                    iD -= aS[0]
                else:
                    j = (i - 1) * 2
                    iD -= sum(aS[j - 1 : j + 1])
                j = (i + K - 1) * 2
                iD += sum(aS[j : j + 2])
                if iMax < iD:
                    iMax = iD
            print(iMax)


眠い()

# 尺取を累積和にかえてみた
def 眠い():
    N, K = [int(_) for _ in input().split()]
    aS = [0] * N
    iS = 0
    iC = 0
    for s in eval(input()):
        if s == "0":
            if iS % 2:
                aS[iS] = iC
                iS += 1
                iC = 1
            else:
                iC += 1
        else:
            if iS % 2:
                iC += 1
            else:
                aS[iS] = iC
                iS += 1
                iC = 1
    if iC:
        if s == "0":
            if iS % 2:
                aS[iS] = 0
                iS += 1
                aS[iS] = iC
            else:
                if len(aS) < iS + 1:
                    aS.append(0)
                    aS[iS] = iC
                else:
                    aS[iS] = iC
        else:
            if iS % 2:
                if len(aS) < iS + 1:
                    aS.append(0)
                    aS[iS] = iC
                else:
                    aS[iS] = iC
            else:
                aS[iS] = 0
                iS += 1
                aS[iS] = iC
    aS = aS[: iS + 1]
    iL = len(aS)
    accS = [0] * (iL + 3)
    for i in range(iL):
        accS[i + 1] = aS[i] + accS[i]
    accS[-2] = accS[-3]
    iLP = iL // 2
    if iL % 2:
        iLP += 1
        if iLP <= K:
            print(N)
            exit()
    else:
        if iLP <= K:
            print(N)
            exit()
    print((max(accS[(i + K) * 2] - accS[i * 2 - 1] for i in range(iLP - K + 1))))


眠い()

+# 尺取を累積和にかえてみた +    accS = [0] * (iL + 3) +    for i in range(iL): +        accS[i + 1] = aS[i] + accS[i] +    accS[-2] = accS[-3] -        else: -            iD = sum(aS[: 2 * K]) -            iMax = iD -            for i in range(1, iLP - K + 1): -                if i == 1: -                    iD -= aS[0] -                else: -                    j = (i - 1) * 2 -                    iD -= sum(aS[j - 1 : j + 1]) -                if i == iLP - K: -                    iD += aS[-1] -                else: -                    j = (i + K - 1) * 2 -                    iD += sum(aS[j : j + 2]) -                if iMax < iD: -                    iMax = iD -            print(iMax) +            exit() -        else: -            iD = sum(aS[: 2 * K]) -            iMax = iD -            for i in range(1, iLP - K + 1): -                if i == 1: -                    iD -= aS[0] -                else: -                    j = (i - 1) * 2 -                    iD -= sum(aS[j - 1 : j + 1]) -                j = (i + K - 1) * 2 -                iD += sum(aS[j : j + 2]) -                if iMax < iD: -                    iMax = iD -            print(iMax) +            exit() +    print((max(accS[(i + K) * 2] - accS[i * 2 - 1] for i in range(iLP - K + 1))))