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 = str(input())
  
  # count sequence man and memo the cnt in group
  man_groups = []
  same_cnt = 0
  last_man = ""
  for i in range(N):
      cur_man = S[i]
      if cur_man != last_man:
          if same_cnt > 0:
              if last_man == "0":
                  same_cnt *= -1
              man_groups.append(same_cnt)
          same_cnt = 1
      else:
          same_cnt += 1
      last_man = cur_man
  if same_cnt > 0:
      if last_man == "0":
          same_cnt *= -1
      man_groups.append(same_cnt)
  
  # count max from evey
  sum_list = []
  end_pos = 2 * K if man_groups[0] > 0 else 2 * K - 1
  end_pos = min(end_pos, len(man_groups) - 1)
  last_max = sum(map(abs, man_groups[0 : end_pos + 1]))
  sum_list.append(last_max)
  for i in range(1, len(man_groups)):
      if end_pos >= len(man_groups) - 1:
          break
      last_max -= abs(man_groups[i - 1])
      if man_groups[i] > 0:
          next_end_pos = min(end_pos + 2, len(man_groups) - 1)
          man_groups_to_add = man_groups[end_pos + 1 : next_end_pos + 1]
          last_max += sum(map(abs, man_groups_to_add))
          end_pos = next_end_pos
      sum_list.append(last_max)
  
  # print(sum_list)
  # print(sum_list)
  print(max(sum_list))
  
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."}]