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

l = list(map(int,input()))
ll = []
p = l[0]
co = 1
ppp = 0
su = 0
for i in range(n-1):
    if p == l[i+1]:
        co += 1
    else:
        if p == 0:
            ppp += 1
        ll.append([p,co])
        p = l[i+1]
        co = 1
if p == 0:
    ppp += 1
ll.append([p,co])
if len(ll) == 1:
    print(n)
else:
    if ppp <= k:
        print(n)
    else:
        ko = 0
        if ll[0][0] == 0:
            if ll[-1][0] == 0:
                for i in range(ppp-k):
                    if i == 0:
                        for j in range(2*k):
                            ko += ll[j][1]
                        su = max(su,ko)
                        ko = 0
                    elif i == co - k - 1:
                        for j in range(2*k):
                            ko += ll[-(j+1)][1]
                        su = max(su,ko)
                        ko = 0
                    else:
                        for j in range(2*k+1):
                            ko += ll[2*i+j][1]
                        su = max(su,ko)
                        ko = 0
            else:
                for i in range(ppp-k+1):
                    if i == 0:
                        for j in range(2*k):
                            ko += ll[j][1]
                        su = max(su,ko)
                        ko = 0
                    else:
                        for j in range(2*k+1):
                            ko += ll[2*i+j][1]
                        su = max(su,ko)
                        ko = 0

        else:
            if ll[-1][0] == 1:
                for i in range(ppp-k+1):
                    for j in range(2*k+1):
                        ko += ll[2*i+j][1]
                    su = max(su,ko)
                    ko = 0
            else:
                for i in range(ppp-k):
                    if i == co-k-1:
                        for j in range(2*k):
                            ko += ll[j][1]
                        su = max(su,ko)
                        ko = 0
                    else:
                        for j in range(2*k+1):
                            ko += ll[2*i+j][1]
                        su = max(su,ko)
                        ko = 0
        print(su)

### FIXED CODE ###

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

l = list(map(int,input()))
ll = []
p = l[0]
co = 1
ppp = 0
su = 0
lll = []
for i in range(n-1):
    if p == l[i+1]:
        co += 1
    else:
        if p == 0:
            ppp += 1
        ll.append([p,co])
        p = l[i+1]
        co = 1
if p == 0:
    ppp += 1
ll.append([p,co])
co = 0

if len(ll) == 1:
    print(n)
    exit(0)
if ppp <= k:
    print(n)
    exit(0)
if ll[0][0] == 0:
    if ll[-1][0] == 0:
        for i in range(2*k):
            co += ll[i][1]
        lll.append(co)
        co -= ll[0][1]
        for i in range(ppp-k):
            if ppp-k-1 == i and i == 0:
                co += ll[-1][1]
                lll.append(co)
            elif ppp-k-1 == i:
                co += ll[-1][1] - (ll[i*2-1][1] + ll[i*2][1])
                lll.append(co)
            elif i == 0:
                co += ll[i*2+1+2*k][1] + ll[i*2+2*k][1]
                lll.append(co)
            else:
                co += ll[i*2+1+2*k][1] + ll[i*2+2*k][1] - (ll[i*2-1][1] + ll[i*2][1])
                lll.append(co)

    else:
        for i in range(2*k):
            co += ll[i][1]
        lll.append(co)
        co -= ll[0][1]
        for i in range(ppp-k):
            if i == 0:
                co += ll[i*2+1+2*k][1] + ll[i*2+2*k][1]
                lll.append(co)
            else:
                co += ll[i*2+1+2*k][1] + ll[i*2+2*k][1] - (ll[i*2-1][1] + ll[i*2][1])
                lll.append(co)
else:
    if ll[-1][0] == 1:
        for i in range(2*k+1):
            co += ll[i][1]
        lll.append(co)
        co -= ll[0][1] + ll[1][1]
        for i in range(ppp-k):
            if i == 0:
                co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1]
                lll.append(co)
            else:
                co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1] - (ll[i*2][1] + ll[i*2+1][1])
                lll.append(co)
    else:
        for i in range(2*k+1):
            co += ll[i][1]
        lll.append(co)
        co -= ll[0][1] + ll[1][1]
        for i in range(ppp-k):
            if ppp-k-1 == i and i == 0:
                co += ll[-1][1]
                lll.append(co)
            elif ppp-k-1 == i:
                co += ll[-1][1] - (ll[i*2][1] + ll[i*2+1][1])
                lll.append(co)
            elif i == 0:
                co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1]
                lll.append(co)
            else:
                co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1] - (ll[i*2][1] + ll[i*2+1][1])
                lll.append(co)
print(max(lll))