n, k = list(map(int,input().split()))
arr = list(map(int,input().split()))
#print(arr) # must list in py3
i, j = 0,0
length =0
while j<len(arr):
    if arr[j] == 1:
        j+=1
    elif k >0:
        k-=1
        j+=1
    else:
        length =max(j-i,length) #length!
        while i<j and arr[i] ==1:
            i+=1
        i+=1# i +1
        j+=1
length =max(j-i,length)
print(length)