### BUGGY CODE ###

n,k=map(int,input().split())
s=input()
s_list=[]
first=s[0]
last=s[n-1]
state=first
length=1
for i in range(1,n):
    if (state=='0' and s[i]=='0') or (state=='1' and s[i]=='1'):
        state=s[i]
        length=length+1
    else:
        state=s[i]
        s_list.append(length)
        length=1
s_list.append(length)
if first=='0' and last=='0':
    if (len(s_list)+1)/2<=k:
        Max=n
    else:
        p_list=s_list[0:2*k]
        Max=sum(p_list)
        i=1
        while i+2*k+1<n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
        p_list=s_list[n-2*k:]
        if sum(p_list)>Max:
            Max=sum(p_list)
elif first=='0' and last=='1':
    if len(s_list)/2<=k:
        Max=n
    else:
        p_list=s_list[0:2*k]
        Max=sum(p_list)
        i=1
        while i+2*k+1<=n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
elif first=='1' and last=='0':
    if len(s_list)/2<=k:
        Max=n
    else:
        p_list=s_list[0:2*k+1]
        Max=sum(p_list)
        i=2
        while i+2*k+1<n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
        p_list=s_list[n-2*k:]
        if sum(p_list)>Max:
            Max=sum(p_list)
elif first=='1' and last=='1':
    if (len(s_list)-1)/2<=k:
        Max=n
    else:
        p_list=s_list[0:2*k+1]
        Max=sum(p_list)
        i=2
        while i+2*k+1<=n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
print(Max)


### FIXED CODE ###

n,k=map(int,input().split())
s=input()
s_list=[]
first=s[0]
last=s[n-1]
state=first
length=1
for i in range(1,n):
    if (state=='0' and s[i]=='0') or (state=='1' and s[i]=='1'):
        state=s[i]
        length=length+1
    else:
        state=s[i]
        s_list.append(length)
        length=1
s_list.append(length)
m=len(s_list)
if first=='0' and last=='0':
    if (len(s_list)+1)/2<=k:
        Max=n
    else:
        p_list=s_list[0:2*k]
        Sum=sum(p_list)
        Max=Sum
        i=1
        p_list=s_list[i:i+2*k+1]
        Sum=sum(p_list)
        if Sum>Max:
            Max=Sum
        i=i+2
        while i+2*k<m-1:
            Sum=Sum-s_list[i-2]-s_list[i-1]+s_list[i+2*k-1]+s_list[i+2*k]
            if Sum>Max:
                Max=Sum
            i=i+2
        p_list=s_list[m-2*k:]
        if sum(p_list)>Max:
            Max=sum(p_list)
elif first=='0' and last=='1':
    if len(s_list)/2<=k:
        Max=n
    else:
        p_list=s_list[0:2*k]
        Sum=sum(p_list)
        Max=Sum
        i=1
        p_list=s_list[i:i+2*k+1]
        Sum=sum(p_list)
        if Sum>Max:
            Max=Sum
        i=i+2
        while i+2*k<=m-1:
            Sum=Sum-s_list[i-2]-s_list[i-1]+s_list[i+2*k-1]+s_list[i+2*k]
            if Sum>Max:
                Max=Sum
            i=i+2
elif first=='1' and last=='0':
    if len(s_list)/2<=k:
        Max=n
    else:
        p_list=s_list[0:2*k+1]
        Sum=sum(p_list)
        Max=Sum
        i=2
        while i+2*k<m-1:
            Sum=Sum-s_list[i-2]-s_list[i-1]+s_list[i+2*k-1]+s_list[i+2*k]
            if Sum>Max:
                Max=Sum
            i=i+2
        p_list=s_list[m-2*k:]
        if sum(p_list)>Max:
            Max=sum(p_list)
elif first=='1' and last=='1':
    if (len(s_list)-1)/2<=k:
        Max=n
    else:
        p_list=s_list[0:2*k+1]
        Sum=sum(p_list)
        Max=Sum
        i=2
        while i+2*k<=m-1:
            Sum=Sum-s_list[i-2]-s_list[i-1]+s_list[i+2*k-1]+s_list[i+2*k]
            if Sum>Max:
                Max=Sum
            i=i+2
print(Max)