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

l=eval(input())

b=True

if l[0]=="1":

  b=True

else:

  b=False

l1=[]

c=1

l11=l[0]

for i in range(1,len(l)):

  if l[i]!=l[i-1]:

    l1.append(c)

    c=1

  else:

    c+=1

l1.append(c)

if b:

  if k>=len(l1)//2:

    print(n)

  else:

    l2=[]

    c1=0

    for i in range(0,(len(l1)//2)):

      c1+=l1[i*2+1]+l1[i*2]

      l2.append(c1)

    if len(l1)%2==1:

      c2=l2[k-1]+l1[2*k]

      for j in range(k,len(l2)):

        c3=l2[j]-l2[j-k]+l1[2*(j+1)]

        if c3>c2:

          c2=c3

      print(c2)

    else:

      c2=l2[k-1]+l1[2*k]

      for j in range(k,len(l2)-1):

        c3=l2[j]-l2[j-k]+l1[2*(j+1)]

        if c3>c2:

          c2=c3

      c3=l2[-1]-l2[-1-k]

      if c3>c2:

        c2=c3

      print(c2)

else:

  if k>=(len(l1)//2)+1:

    print(n)

  else:

    l2=[l1[0]]

    c1=l1[0]

    if len(l1)%2==1:

      for i in range(1,(len(l1)//2)+1):

        c1+=l1[2*i]+l1[2*i-1]

        l2.append(c1)

      c2=l2[k-1]+l1[2*k-1]

      for i in range(k,len(l2)-1):

        c3=l2[i]-l2[i-k]+l1[i*2+1]

        if c3>c2:

          c2=c3

      c3=l2[len(l2)-1]-l2[len(l2)-1-k]

      if c3>c2:

        c2=c3

      print(c2)

    else:

      for i in range(1,(len(l1)//2)):

        c1+=l1[2*i]+l1[2*i-1]

        l2.append(c1)

      c2=l2[k-1]+l1[2*k-1]

      for i in range(k,len(l2)):

        c3=l2[i]-l2[i-k]+l1[i*2+1]

        if c3>c2:

          c2=c3

      print(c2) 
n,k=list(map(int,input().split()))

w=eval(input())

l=[]

c=0

w="1"+w

for i in range(1,1+n):

  if w[i]!=w[i-1]:

    l.append(c)

    c=1

  else:

    c+=1

l.append(c)

if k>=len(l)//2:

  print(n)

else:

  if w[-1]=="0":

    l.append(0)

  s=l[0]

  for i in range(1,1+k):

    s+=l[2*i]+l[2*i-1]

  s1=s

  c1=l[0]+l[1]

  for i in range(1,(len(l)+1)//2-k):

    s1=s1-l[2*i-2]-l[2*i-1]+l[2*i-1+2*k]+l[2*i+2*k]

    if s1>s:

      s=s1

  print(s)
n, k = list(map(int, input().split()))
l = eval(input())
b = True
if l[0] == "1":
    b = True
else:
    b = False
l1 = []
c = 1
l11 = l[0]
for i in range(1, len(l)):
    if l[i] != l[i - 1]:
        l1.append(c)
        c = 1
    else:
        c += 1
l1.append(c)
if b:
    if k >= len(l1) // 2:
        print(n)
    else:
        l2 = []
        c1 = 0
        for i in range(0, (len(l1) // 2)):
            c1 += l1[i * 2 + 1] + l1[i * 2]
            l2.append(c1)
        if len(l1) % 2 == 1:
            c2 = l2[k - 1] + l1[2 * k]
            for j in range(k, len(l2)):
                c3 = l2[j] - l2[j - k] + l1[2 * (j + 1)]
                if c3 > c2:
                    c2 = c3
            print(c2)
        else:
            c2 = l2[k - 1] + l1[2 * k]
            for j in range(k, len(l2) - 1):
                c3 = l2[j] - l2[j - k] + l1[2 * (j + 1)]
                if c3 > c2:
                    c2 = c3
            c3 = l2[-1] - l2[-1 - k]
            if c3 > c2:
                c2 = c3
            print(c2)
else:
    if k >= (len(l1) // 2) + 1:
        print(n)
    else:
        l2 = [l1[0]]
        c1 = l1[0]
        if len(l1) % 2 == 1:
            for i in range(1, (len(l1) // 2) + 1):
                c1 += l1[2 * i] + l1[2 * i - 1]
                l2.append(c1)
            c2 = l2[k - 1] + l1[2 * k - 1]
            for i in range(k, len(l2) - 1):
                c3 = l2[i] - l2[i - k] + l1[i * 2 + 1]
                if c3 > c2:
                    c2 = c3
            c3 = l2[len(l2) - 1] - l2[len(l2) - 1 - k]
            if c3 > c2:
                c2 = c3
            print(c2)
        else:
            for i in range(1, (len(l1) // 2)):
                c1 += l1[2 * i] + l1[2 * i - 1]
                l2.append(c1)
            c2 = l2[k - 1] + l1[2 * k - 1]
            for i in range(k, len(l2)):
                c3 = l2[i] - l2[i - k] + l1[i * 2 + 1]
                if c3 > c2:
                    c2 = c3
            print(c2)

n, k = list(map(int, input().split()))
w = eval(input())
l = []
c = 0
w = "1" + w
for i in range(1, 1 + n):
    if w[i] != w[i - 1]:
        l.append(c)
        c = 1
    else:
        c += 1
l.append(c)
if k >= len(l) // 2:
    print(n)
else:
    if w[-1] == "0":
        l.append(0)
    s = l[0]
    for i in range(1, 1 + k):
        s += l[2 * i] + l[2 * i - 1]
    s1 = s
    c1 = l[0] + l[1]
    for i in range(1, (len(l) + 1) // 2 - k):
        s1 = s1 - l[2 * i - 2] - l[2 * i - 1] + l[2 * i - 1 + 2 * k] + l[2 * i + 2 * k]
        if s1 > s:
            s = s1
    print(s)

-l = eval(input()) -b = True -if l[0] == "1": -    b = True -else: -    b = False -l1 = [] -c = 1 -l11 = l[0] -for i in range(1, len(l)): -    if l[i] != l[i - 1]: -        l1.append(c) +w = eval(input()) +l = [] +c = 0 +w = "1" + w +for i in range(1, 1 + n): +    if w[i] != w[i - 1]: +        l.append(c) -l1.append(c) -if b: -    if k >= len(l1) // 2: -        print(n) -    else: -        l2 = [] -        c1 = 0 -        for i in range(0, (len(l1) // 2)): -            c1 += l1[i * 2 + 1] + l1[i * 2] -            l2.append(c1) -        if len(l1) % 2 == 1: -            c2 = l2[k - 1] + l1[2 * k] -            for j in range(k, len(l2)): -                c3 = l2[j] - l2[j - k] + l1[2 * (j + 1)] -                if c3 > c2: -                    c2 = c3 -            print(c2) -        else: -            c2 = l2[k - 1] + l1[2 * k] -            for j in range(k, len(l2) - 1): -                c3 = l2[j] - l2[j - k] + l1[2 * (j + 1)] -                if c3 > c2: -                    c2 = c3 -            c3 = l2[-1] - l2[-1 - k] -            if c3 > c2: -                c2 = c3 -            print(c2) +l.append(c) +if k >= len(l) // 2: +    print(n) -    if k >= (len(l1) // 2) + 1: -        print(n) -    else: -        l2 = [l1[0]] -        c1 = l1[0] -        if len(l1) % 2 == 1: -            for i in range(1, (len(l1) // 2) + 1): -                c1 += l1[2 * i] + l1[2 * i - 1] -                l2.append(c1) -            c2 = l2[k - 1] + l1[2 * k - 1] -            for i in range(k, len(l2) - 1): -                c3 = l2[i] - l2[i - k] + l1[i * 2 + 1] -                if c3 > c2: -                    c2 = c3 -            c3 = l2[len(l2) - 1] - l2[len(l2) - 1 - k] -            if c3 > c2: -                c2 = c3 -            print(c2) -        else: -            for i in range(1, (len(l1) // 2)): -                c1 += l1[2 * i] + l1[2 * i - 1] -                l2.append(c1) -            c2 = l2[k - 1] + l1[2 * k - 1] -            for i in range(k, len(l2)): -                c3 = l2[i] - l2[i - k] + l1[i * 2 + 1] -                if c3 > c2: -                    c2 = c3 -            print(c2) +    if w[-1] == "0": +        l.append(0) +    s = l[0] +    for i in range(1, 1 + k): +        s += l[2 * i] + l[2 * i - 1] +    s1 = s +    c1 = l[0] + l[1] +    for i in range(1, (len(l) + 1) // 2 - k): +        s1 = s1 - l[2 * i - 2] - l[2 * i - 1] + l[2 * i - 1 + 2 * k] + l[2 * i + 2 * k] +        if s1 > s: +            s = s1 +    print(s)