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: # -*- coding: utf-8 -*-
  
  # スペース区切りの整数の入力
  n, k = map(int, input().split())
  
  # 01文字列の入力
  s = str(input())
  
  # 01文字列を配列に一文字ずつ格納
  hito = list(s)
  
  irekaeCnt = 0
  
  listSakadachiCnt = []
  
  sakadachiCnt = 0
  tmpMaxCnt = 0
  # 初期状態での連続逆立ち人数
  for i in range(len(hito)):
  
      if hito[i] == "1":
          sakadachiCnt += 1
      else:
          if tmpMaxCnt < sakadachiCnt:
              tmpMaxCnt = sakadachiCnt
          sakadachiCnt = 0
  
  if tmpMaxCnt < sakadachiCnt:
      tmpMaxCnt = sakadachiCnt
  
  listSakadachiCnt.append(tmpMaxCnt)
  
  sakadachiCnt = 0
  tmpMaxCnt = 0
  
  # 0の出現箇所
  listZeroFrom = []
  listZeroTO = []
  prevIsZero = False
  
  # 0の開始終了位置
  for i in range(len(hito)):
      if hito[i] == "0" and prevIsZero == False:
          listZeroFrom.append(i)
          prevIsZero = True
      elif hito[i] == "1" and prevIsZero == True:
          listZeroTO.append(i)
          prevIsZero = False
  if prevIsZero == True:
      listZeroTO.append(len(hito) - 1)
      prevIsZero = False
  
  
  # n回まで入れ替え可能
  for j in range(n):
      # 01文字列を配列に一文字ずつ格納
      hito = list(s)
      irekaeCnt = 0
  
      # if len(listZeroFrom) < j :
      #     for f in range(listZeroFrom[j],listZeroTO[j]):
      #         hito[f] = "1"
      #     irekaeCnt += 1
      #     j += 1
  
      for k in range(len(listZeroFrom)):
          # print("len(listZeroFrom):{},len(listZeroFrom):{},k:{}".format(len(listZeroFrom),len(listZeroTO),str(k)))
          for l in range(listZeroFrom[k], listZeroTO[k]):
              # print("hito[{}]:{}".format(l,hito[l]))
              hito[l] = "1"
              # print("hito[{}]:{}".format(l,hito[l]))
          irekaeCnt += 1
  
          # 連続逆立ち人数
          sakadachiCnt = 0
          tmpMaxCnt = 0
          for m in range(len(hito)):
              # print("hito[{}]:{}".format(m,hito[m]))
  
              if hito[m] == "1":
                  sakadachiCnt += 1
              else:
                  if tmpMaxCnt < sakadachiCnt:
                      tmpMaxCnt = sakadachiCnt
                  sakadachiCnt = 0
  
          if tmpMaxCnt < sakadachiCnt:
              tmpMaxCnt = sakadachiCnt
  
          listSakadachiCnt.append(tmpMaxCnt)
  
          if irekaeCnt == j:
  
              sakadachiCnt = 0
              tmpMaxCnt = 0
              # 連続逆立ち人数
              for m in range(len(hito)):
                  # print("hito[{}]:{}".format(m,hito[m]))
  
                  if hito[m] == "1":
                      sakadachiCnt += 1
                  else:
                      if tmpMaxCnt < sakadachiCnt:
                          tmpMaxCnt = sakadachiCnt
                      sakadachiCnt = 0
  
              if tmpMaxCnt < sakadachiCnt:
                  tmpMaxCnt = sakadachiCnt
  
              listSakadachiCnt.append(tmpMaxCnt)
  
          # 01文字列を配列に一文字ずつ格納
          hito = list(s)
          irekaeCnt = 0
  
  # for p in range(len(listSakadachiCnt)):
  #     print(str(listSakadachiCnt[p]))
  
  listSakadachiCnt.sort(reverse=True)
  
  # 出力
  print(str(listSakadachiCnt[0]))
  
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."}]