### BUGGY CODE ###

import re

input_str=input()
N=int(input_str.split()[0])
K=int(input_str.split()[1])
str_teams = str(input())
sub_str_teams = str_teams

def next_check_val(check_val):
  if check_val == '1':
    return '0'
  else:
    return '1'

cur_check_val = str_teams[0]
teams_group = []
teams_state = ''

## 直立/逆立ちのグループに分ける処理
for i in range(N):
  person = str_teams[i]
  if str_teams[i] == cur_check_val:
    teams_state = teams_state + str_teams[i]
  else:
    teams_group.append(teams_state)
    teams_state = str_teams[i]
    cur_check_val = next_check_val(cur_check_val)

teams_group.append(teams_state)
#print(teams_group)

## 0グループの個数がK以下の場合
## 人数を回答にしてexitする
count_0 = 0
for i in range(len(teams_group)):
  if teams_group[i].startswith('0'):
    count_0 += 1
if count_0 <= K:
  print(N)
  exit()

sum_handstand = [] ## 累積和を格納するリスト

for i in range(len(teams_group)):
  handstands = 0     ## 各累積和を一時的に格納する変数
  if ('0' in teams_group[i]):
    for k in range(K*2):
      try:
        handstands += len(teams_group[i+k])
      except IndexError:
        pass
  else:
    for k in range(K*2+1):
      try:
        handstands += len(teams_group[i+k])
      except IndexError:
        pass
  sum_handstand.append(handstands)


### 最初の累積和を計算する処理
### 先頭が0か1かによって処理を分割している
#if ('0' in teams_group[0]):
#  for k in range(K*2):
#    handstands += len(teams_group[k])
#else:
#  for k in range(K*2+1):
#    handstands += len(teams_group[k])
#
#sum_handstand.append(handstands)
#
### 途中の累積和を計算する処理
#for i in range(1,len(teams_group)-(K*2)):
#  ## 先頭が0か1かによって処理を分割している
#  if ('0' in teams_group[i]):
#    #print(sum_handstand[i-1] , teams_group[i-1])
#    handstands = sum_handstand[i-1] - len(teams_group[i-1])
#  else:
#    #print(sum_handstand[i-1] , teams_group[i-1] , teams_group[i+K+1] , teams_group[i+K+2])
#    handstands = sum_handstand[i-1] - len(teams_group[i-1]) + (len(teams_group[i+K+1])+len(teams_group[i+K+2]))
#  sum_handstand.append(handstands)
#
#handstands = 0
### 最後の累積和を計算する処理
#if ('0' in teams_group[-1]):
#  for k in range(0,K*2):
#    handstands += len(teams_group[len(teams_group)-2*K+k])
#  sum_handstand.append(handstands)


print(max(sum_handstand))

### FIXED CODE ###

import re

input_str=input()
N=int(input_str.split()[0])
K=int(input_str.split()[1])
str_teams = str(input())
sub_str_teams = str_teams

def next_check_val(check_val):
  if check_val == '1':
    return '0'
  else:
    return '1'

cur_check_val = str_teams[0]
teams_group = []
teams_state = ''

## 直立/逆立ちのグループに分ける処理
for i in range(N):
  person = str_teams[i]
  if str_teams[i] == cur_check_val:
    teams_state = teams_state + str_teams[i]
  else:
    teams_group.append(teams_state)
    teams_state = str_teams[i]
    cur_check_val = next_check_val(cur_check_val)

teams_group.append(teams_state)
#print(teams_group)

## 0グループの個数がK以下の場合
## 人数を回答にしてexitする
count_0 = 0
for i in range(len(teams_group)):
  if teams_group[i].startswith('0'):
    count_0 += 1
if count_0 <= K:
  print(N)
  exit()

sum_handstand = [] ## 累積和を格納するリスト
handstands = 0     ## 各累積和を一時的に格納する変数


## 最初の累積和を計算する処理
## 先頭が0か1かによって処理を分割している
if ('0' in teams_group[0]):
  for k in range(K*2):
    handstands += len(teams_group[k])
else:
  for k in range(K*2+1):
    handstands += len(teams_group[k])

sum_handstand.append(handstands)

## 途中の累積和を計算する処理
for i in range(1,len(teams_group)-(K*2)):
  ## 先頭が0か1かによって処理を分割している
  if ('0' in teams_group[i]):
    handstands = sum_handstand[i-1]
  else:
    if i == 1:
      handstands = sum_handstand[i-1] - len(teams_group[i-1]) + (len(teams_group[i+2*K-1])+len(teams_group[i+2*K]))
    else:
      handstands = sum_handstand[i-1] - (len(teams_group[i-1])+len(teams_group[i-2])) + (len(teams_group[i+2*K-1])+len(teams_group[i+2*K]))
  sum_handstand.append(handstands)

handstands = 0
## 最後の累積和を計算する処理
if ('0' in teams_group[-1]):
  for k in range(0,K*2):
    handstands += len(teams_group[len(teams_group)-2*K+k])
  sum_handstand.append(handstands)


#print(sum_handstand)
print(max(sum_handstand))