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: import sys
  
  N, K = [int(x) for x in input().split()]  # N:Sの長さ K:操作を行える回数の最大値
  S = [int(x) for x in list(input())]  # S:0と1から成る列
  index = [0]  # index:Sにおいて0と1が切り替わる部分の添字を集めたリスト
  length = [0]  # length:1が連続して並んでいる長さの最大値の候補を集めたリスト
  zeros = 0  # zeros:Sにおいて0が連続して並んでいる箇所がいくつあるか
  
  for i in range(0, len(S) - 1):  # indexの要素を取得
      if S[i] != S[i + 1]:  # 0と1の変わり目を探索
          index.append(i + 1)
  
  if S[0] == 0:  # Sが0から始まる場合
  
      for i in range(len(index)):  # zerosの値を取得
          if len(index) % 2 == 0:  # indexの長さが偶数である場合
              zeros = int(len(index) / 2)
          else:  # indexの長さが奇数である場合
              zeros = int((len(index) + 1) / 2)
  
      for i in range(len(index)):  # max(length)の初期値を取得
          if S[len(S) - 1] == 0:  # Sが0で終わっている場合
              if i % 2 == 1:
                  length.append(index[i + 1] - index[i])
          else:  # Sが1で終わっている場合
              if i % 2 == 1 and (i + 1) < len(index):
                  length.append(index[i + 1] - index[i])
              elif i % 2 == 1 and (i + 1) == len(index):  # 最後の1の連続を処理
                  length.append((len(S) - 1) - index[i] + 1)
  
      for i in range(
          len(index)
      ):  # Sのindex[i]番目を左端としたときの1の連続回数の最大値をそれぞれ求める
          if K >= zeros:  # Kがzeros以上なら0の連続を全て1に置き換えて終了
              print(len(S))
              sys.exit()
  
          elif i + (2 * K) <= (
              len(index) - 1
          ):  # 添字が飛び出ないように注意（飛び出るようなやつはそもそも最大値の候補にならない）
              if i % 2 == 0:  # 左端が0の場合
                  length.append(index[(i + (2 * K) - 1) + 1] - index[i])
              else:  # 左端が1の場合
                  if i + (2 * K) < (len(index) - 1):
                      length.append(index[i + (2 * K) + 1] - index[i])
                  elif i + (2 * K) == (len(index) - 1):
                      length.append((len(S) - 1) - index[i] + 1)
  
      print(max(length))
      sys.exit()
  
  else:  # Sが1から始まる場合
  
      for i in range(len(index)):  # zerosの値を取得
          if len(index) % 2 == 0:  # indexの長さが偶数である場合
              zeros = int(len(index) / 2)
          else:  # indexの長さが奇数である場合
              zeros = int((len(index) - 1) / 2)
  
      for i in range(len(index)):  # max(length)の初期値を取得
          if S[len(S) - 1] == 0:  # Sが0で終わっている場合
              if i % 2 == 0:
                  length.append(index[i + 1] - index[i])
          else:  # Sが1で終わっている場合
              if i % 2 == 0 and (i + 1) < len(index):
                  length.append(index[i + 1] - index[i])
              elif i % 2 == 0 and (i + 1) == len(index):  # 最後の1の連続を処理
                  length.append((len(S) - 1) - index[i] + 1)
  
      for i in range(
          len(index)
      ):  # Sのindex[i]番目を左端としたときの1の連続回数の最大値をそれぞれ求める
          if K >= zeros:  # Kがzeros以上なら0の連続を全て1に置き換えて終了
              print(len(S))
              sys.exit()
  
          elif i + (2 * K) <= (
              len(index) - 1
          ):  # 添字が飛び出ないように注意（飛び出るようなやつはそもそも最大値の候補にならない）
              if i % 2 == 0:  # 左端が1の場合
                  if i + (2 * K) < (len(index) - 1):
                      length.append(index[i + (2 * K) + 1] - index[i])
                  elif i + (2 * K) == (len(index) - 1):
                      length.append((len(S) - 1) - index[i] + 1)
  
              else:  # 左端が0の場合
                  length.append(index[(i + (2 * K) - 1) + 1] - index[i])
  
      print(max(length))
      sys.exit()
  
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."}]