def solve():

  N, K = list(map(int, input().split()))

  _S = eval(input())

  S = []

  b = _S[0]

  s = 0

  if b == '0': S.append(0)

  for _s in _S:

    if b == _s:

      s = s + 1

    else:

      b = _s

      S.append(s)

      s = 1

  S.append(s)

  if b == '0': S.append(0)



  num = min(len(S), 2 * K + 1)

  # n = sum(S[0:num if _S[0] == '1' else (num - 1)])

  n = sum(S[0:num])

  m = n

  # for i in range(0 if _S[0] == '1' else -1, len(S) - num, 2):

  for i in range(0, len(S) - num, 2):

    n = n - sum(S[i:i+2])

    n = n + sum(S[i + num:i + num + 2])

    m = max(m, n)



  return m



print((solve()))
def solve():

  N, K = list(map(int, input().split()))

  s = eval(input())

  S = []

  b = s[0]

  cnt = 0



  if s[0] == '0': S.append(0)

  for c in s:

    if b == c: cnt = cnt + 1

    else:

      b = c

      S.append(cnt)

      cnt = 1

  S.append(cnt)

  if s[-1] == '0': S.append(0)



  num = min(len(S), 2 * K + 1)

  part = sum(S[0:num])

  ans = part



  for i in range(0, len(S) - num, 2):

    part = part - sum(S[i:i+2]) + sum(S[i + num:i + num + 2])

    ans = max(ans, part)



  return ans



print((solve()))

def solve():
    N, K = list(map(int, input().split()))
    _S = eval(input())
    S = []
    b = _S[0]
    s = 0
    if b == "0":
        S.append(0)
    for _s in _S:
        if b == _s:
            s = s + 1
        else:
            b = _s
            S.append(s)
            s = 1
    S.append(s)
    if b == "0":
        S.append(0)
    num = min(len(S), 2 * K + 1)
    # n = sum(S[0:num if _S[0] == '1' else (num - 1)])
    n = sum(S[0:num])
    m = n
    # for i in range(0 if _S[0] == '1' else -1, len(S) - num, 2):
    for i in range(0, len(S) - num, 2):
        n = n - sum(S[i : i + 2])
        n = n + sum(S[i + num : i + num + 2])
        m = max(m, n)
    return m


print((solve()))

def solve():
    N, K = list(map(int, input().split()))
    s = eval(input())
    S = []
    b = s[0]
    cnt = 0
    if s[0] == "0":
        S.append(0)
    for c in s:
        if b == c:
            cnt = cnt + 1
        else:
            b = c
            S.append(cnt)
            cnt = 1
    S.append(cnt)
    if s[-1] == "0":
        S.append(0)
    num = min(len(S), 2 * K + 1)
    part = sum(S[0:num])
    ans = part
    for i in range(0, len(S) - num, 2):
        part = part - sum(S[i : i + 2]) + sum(S[i + num : i + num + 2])
        ans = max(ans, part)
    return ans


print((solve()))

-    _S = eval(input()) +    s = eval(input()) -    b = _S[0] -    s = 0 -    if b == "0": +    b = s[0] +    cnt = 0 +    if s[0] == "0": -    for _s in _S: -        if b == _s: -            s = s + 1 +    for c in s: +        if b == c: +            cnt = cnt + 1 -            b = _s -            S.append(s) -            s = 1 -    S.append(s) -    if b == "0": +            b = c +            S.append(cnt) +            cnt = 1 +    S.append(cnt) +    if s[-1] == "0": -    # n = sum(S[0:num if _S[0] == '1' else (num - 1)]) -    n = sum(S[0:num]) -    m = n -    # for i in range(0 if _S[0] == '1' else -1, len(S) - num, 2): +    part = sum(S[0:num]) +    ans = part -        n = n - sum(S[i : i + 2]) -        n = n + sum(S[i + num : i + num + 2]) -        m = max(m, n) -    return m +        part = part - sum(S[i : i + 2]) + sum(S[i + num : i + num + 2]) +        ans = max(ans, part) +    return ans