output_description: Print the maximum possible number of consecutive people standing on hands
  after at most K directions.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      S
attempt: 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)
  
problem_description: Statement
  
  N people are arranged in a row from left to right.
  
  You are given a string S of length N consisting of `0` and `1`, and a positive
  integer K.
  
  The i-th person from the left is standing on feet if the i-th character of S
  is `0`, and standing on hands if that character is `1`.
  
  You will give the following direction at most K times (possibly zero):
  
  **Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
  flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
  ..., r, the i-th person from the left now stands on hands if he/she was
  standing on feet, and stands on feet if he/she was standing on hands.
  
  Find the maximum possible number of **consecutive** people standing on hands
  after at most K directions.
samples: [{"input": "5 1\n    00010", "output": "4\n    \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n  * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n    11101010110011", "output": "8\n    \n\n* * *"}, {"input": "1 1\n    1", "output": "1\n    \n\nNo directions are necessary."}]