# -*- coding: utf-8 -*-



import sys



def input(): return sys.stdin.readline().strip()

def list2d(a, b, c): return [[c] * b for i in range(a)]

def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]

def ceil(x, y=1): return int(-(-x // y))

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def LIST(): return list(map(int, input().split()))

def Yes(): print('Yes')

def No(): print('No')

def YES(): print('YES')

def NO(): print('NO')

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

MOD = 10 ** 9 + 7



N,K=MAP()

S=eval(input())



L=[]

cnt0=0

# 0始まりの時は番兵的に1の区間0を追加しておく

if S[0]=='0':

    L.append(0)

    cur=0

else:

    cur=1

cnt=0

# 1の区間の長さ、0の区間の長さ、1の区間の長さ...の配列Lを作る

for i in range(N):

    if cur==int(S[i]):

        cnt+=1

    else:

        L.append(cnt)

        if cur==0:

            cnt0+=1

        cnt=1

        # フラグの切り替え

        cur=1-cur

else:

    if cnt!=0:

        L.append(cnt)

        if cur==0:

            cnt0+=1

# 0終わりの時は番兵的に1の区間0を追加しておく

if S[-1]=='0':

    L.append(0)



if cnt0<K:

    # 0区間の数がKより少なかったら、それに合わせて区間和取る長さを短くする

    K=cnt0



# 尺取法

l=0

r=K*2+1

ans=sm=sum(L[:K*2+1])

while l<len(L) and r<len(L):

    for i in range(2):

        sm+=L[r]

        r+=1

        sm-=L[l]

        l+=1

    ans=max(ans, sm)

print(ans)

# -*- coding: utf-8 -*-



import sys



def input(): return sys.stdin.readline().strip()

def list2d(a, b, c): return [[c] * b for i in range(a)]

def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1): return int(-(-x // y))

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes(): print('Yes')

def No(): print('No')

def YES(): print('YES')

def NO(): print('NO')

sys.setrecursionlimit(10 ** 9)

INF = 10 ** 18

MOD = 10 ** 9 + 7



N, K = MAP()

S = eval(input())



# ランレングス圧縮

A = []

# 番兵

if S[0] == '0':

    A.append(0)

cur = S[0]

cnt = 1

for i, s in enumerate(S[1:], 1):

    if s != cur:

        A.append(cnt)

        cnt = 1

        cur = s

    else:

        cnt += 1

A.append(cnt)



# 例外処理

if len(A) == 1:

    print(N)

    exit()



# 番兵

if S[-1] == '0':

    A.append(0)



M = len(A)

ans = sm = sum(A[:K*2+1])

for i in range(K*2+1, M):

    sm += A[i]

    # 今回増やすのが0の区間なら、後ろ2つ減る

    if i % 2 == 1:

        if i-K*2 >= 0:

            sm -= A[i-K*2]

        if i-K*2-1 >= 0:

            sm -= A[i-K*2-1]

    ans = max(ans, sm)

print(ans)

# -*- coding: utf-8 -*-
import sys


def input():
    return sys.stdin.readline().strip()


def list2d(a, b, c):
    return [[c] * b for i in range(a)]


def list3d(a, b, c, d):
    return [[[d] * c for j in range(b)] for i in range(a)]


def ceil(x, y=1):
    return int(-(-x // y))


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def LIST():
    return list(map(int, input().split()))


def Yes():
    print("Yes")


def No():
    print("No")


def YES():
    print("YES")


def NO():
    print("NO")


sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
N, K = MAP()
S = eval(input())
L = []
cnt0 = 0
# 0始まりの時は番兵的に1の区間0を追加しておく
if S[0] == "0":
    L.append(0)
    cur = 0
else:
    cur = 1
cnt = 0
# 1の区間の長さ、0の区間の長さ、1の区間の長さ...の配列Lを作る
for i in range(N):
    if cur == int(S[i]):
        cnt += 1
    else:
        L.append(cnt)
        if cur == 0:
            cnt0 += 1
        cnt = 1
        # フラグの切り替え
        cur = 1 - cur
else:
    if cnt != 0:
        L.append(cnt)
        if cur == 0:
            cnt0 += 1
# 0終わりの時は番兵的に1の区間0を追加しておく
if S[-1] == "0":
    L.append(0)
if cnt0 < K:
    # 0区間の数がKより少なかったら、それに合わせて区間和取る長さを短くする
    K = cnt0
# 尺取法
l = 0
r = K * 2 + 1
ans = sm = sum(L[: K * 2 + 1])
while l < len(L) and r < len(L):
    for i in range(2):
        sm += L[r]
        r += 1
        sm -= L[l]
        l += 1
    ans = max(ans, sm)
print(ans)

# -*- coding: utf-8 -*-
import sys


def input():
    return sys.stdin.readline().strip()


def list2d(a, b, c):
    return [[c] * b for i in range(a)]


def list3d(a, b, c, d):
    return [[[d] * c for j in range(b)] for i in range(a)]


def list4d(a, b, c, d, e):
    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]


def ceil(x, y=1):
    return int(-(-x // y))


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def LIST(N=None):
    return list(MAP()) if N is None else [INT() for i in range(N)]


def Yes():
    print("Yes")


def No():
    print("No")


def YES():
    print("YES")


def NO():
    print("NO")


sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
N, K = MAP()
S = eval(input())
# ランレングス圧縮
A = []
# 番兵
if S[0] == "0":
    A.append(0)
cur = S[0]
cnt = 1
for i, s in enumerate(S[1:], 1):
    if s != cur:
        A.append(cnt)
        cnt = 1
        cur = s
    else:
        cnt += 1
A.append(cnt)
# 例外処理
if len(A) == 1:
    print(N)
    exit()
# 番兵
if S[-1] == "0":
    A.append(0)
M = len(A)
ans = sm = sum(A[: K * 2 + 1])
for i in range(K * 2 + 1, M):
    sm += A[i]
    # 今回増やすのが0の区間なら、後ろ2つ減る
    if i % 2 == 1:
        if i - K * 2 >= 0:
            sm -= A[i - K * 2]
        if i - K * 2 - 1 >= 0:
            sm -= A[i - K * 2 - 1]
    ans = max(ans, sm)
print(ans)

+def list4d(a, b, c, d, e): +    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] + + -def LIST(): -    return list(map(int, input().split())) +def LIST(N=None): +    return list(MAP()) if N is None else [INT() for i in range(N)] -INF = float("inf") +INF = 10**18 -L = [] -cnt0 = 0 -# 0始まりの時は番兵的に1の区間0を追加しておく +# ランレングス圧縮 +A = [] +# 番兵 -    L.append(0) -    cur = 0 -else: -    cur = 1 -cnt = 0 -# 1の区間の長さ、0の区間の長さ、1の区間の長さ...の配列Lを作る -for i in range(N): -    if cur == int(S[i]): +    A.append(0) +cur = S[0] +cnt = 1 +for i, s in enumerate(S[1:], 1): +    if s != cur: +        A.append(cnt) +        cnt = 1 +        cur = s +    else: -    else: -        L.append(cnt) -        if cur == 0: -            cnt0 += 1 -        cnt = 1 -        # フラグの切り替え -        cur = 1 - cur -else: -    if cnt != 0: -        L.append(cnt) -        if cur == 0: -            cnt0 += 1 -# 0終わりの時は番兵的に1の区間0を追加しておく +A.append(cnt) +# 例外処理 +if len(A) == 1: +    print(N) +    exit() +# 番兵 -    L.append(0) -if cnt0 < K: -    # 0区間の数がKより少なかったら、それに合わせて区間和取る長さを短くする -    K = cnt0 -# 尺取法 -l = 0 -r = K * 2 + 1 -ans = sm = sum(L[: K * 2 + 1]) -while l < len(L) and r < len(L): -    for i in range(2): -        sm += L[r] -        r += 1 -        sm -= L[l] -        l += 1 +    A.append(0) +M = len(A) +ans = sm = sum(A[: K * 2 + 1]) +for i in range(K * 2 + 1, M): +    sm += A[i] +    # 今回増やすのが0の区間なら、後ろ2つ減る +    if i % 2 == 1: +        if i - K * 2 >= 0: +            sm -= A[i - K * 2] +        if i - K * 2 - 1 >= 0: +            sm -= A[i - K * 2 - 1]