Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)

print(a)


if s[-1]=='0':
	m=2*k
else:
	m=2*k+1
if n<m or len(a)-m-1<0:
	print(n)
elif len(a)==2 and s[0]=='1' and k==0:
	print(0)
else:
	print(n)
else:
	_max=0
	i=len(a)-1
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		i-=1
	print(_max)

Fixed submission:
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)
if s[-1]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
_max=0
i=len(a)-1
if i- m<0:
	print(n)
else:
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		m=t-m
		i-=1
	if a[i]>_max:
		_max=a[i]
	print(_max)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
tmp=1
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)

#print(a)

if len(a)==2:
	print(a[1])
else:
	if s[0]=='0':
		m=2*k
	else:
		m=2*k+1
	if m>len(s):
		print(len(s))
	else:
		_max=a[m]
		i=1
		while m+i<len(a):
			tmp=a[i+m]-a[i]
			#print(tmp)
			if tmp>_max:
				_max=tmp
			i+=1
		print(_max)


Fixed submission:
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)
if s[-1]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
_max=0
i=len(a)-1
if i- m<0:
	print(n)
else:
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		m=t-m
		i-=1
	if a[i]>_max:
		_max=a[i]
	print(_max)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
tmp=1
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)

#print(a)

if len(a)==2:
	print(a[1])
else:
	if s[0]=='0':
		m=2*k
	else:
		m=2*k+1
	if m>len(s):
		print(len(s))
	else:
		_max=a[m]
		i=1
		while m+i<len(a):
			tmp=a[i+m]-a[i]
			print(tmp)
			if tmp>_max:
				_max=tmp
			i+=1
		print(_max)


Fixed submission:
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)
if s[-1]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
_max=0
i=len(a)-1
if i- m<0:
	print(n)
else:
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		m=t-m
		i-=1
	if a[i]>_max:
		_max=a[i]
	print(_max)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
tmp=1
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)

#print(a)

if len(a)==2:
	print(a[1])
else:
	if s[-1]=='0':
		m=2*k
	else:
		m=2*k+1
	_max=a[m]
	i=len(a)-1
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		i-=1
	print(_max)

Fixed submission:
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)
if s[-1]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
_max=0
i=len(a)-1
if i- m<0:
	print(n)
else:
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		m=t-m
		i-=1
	if a[i]>_max:
		_max=a[i]
	print(_max)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
tmp=1
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)

#print(a)

if len(a)==2:
	print(a[1])
else:
	if s[0]=='0':
		m=2*k
	else:
		m=2*k+1
	_max=a[m]
	i=1
	while m+i<len(a):
		tmp=a[i+m]-a[i]
		print(tmp)
		if tmp>_max:
			_max=tmp
		i+=1
	print(_max)


Fixed submission:
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)
if s[-1]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
_max=0
i=len(a)-1
if i- m<0:
	print(n)
else:
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		m=t-m
		i-=1
	if a[i]>_max:
		_max=a[i]
	print(_max)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
s=input()
a=[]
tmp=1
for i in range(len(s)-1):
	if s[i] == s[i+1]:
		tmp+=1
	else:
		a.append(tmp)
		tmp=1
a.append(tmp)
if s[0]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
_max=a[0]
for i in range(len(a)):
	tmp=sum(a[i:i+m])
	if tmp>_max:
		_max=tmp
	m=t-m
print(_max)


Fixed submission:
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)
if s[-1]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
_max=0
i=len(a)-1
if i- m<0:
	print(n)
else:
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		m=t-m
		i-=1
	if a[i]>_max:
		_max=a[i]
	print(_max)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
s=input()
a=[]
tmp=1
for i in range(len(s)-1):
	if s[i] == s[i+1]:
		tmp+=1
	else:
		a.append(tmp)
		tmp=1
a.append(tmp)

b=[]
b.append(a[0])
if s[0]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
for i in range(len(a)):
	b.append(sum(a[i:i+m]))
	m=t-m
print(max(b))


Fixed submission:
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)
if s[-1]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
_max=0
i=len(a)-1
if i- m<0:
	print(n)
else:
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		m=t-m
		i-=1
	if a[i]>_max:
		_max=a[i]
	print(_max)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
a=[]
tmp=1
for i in range(len(s)-1):
	if s[i] == s[i+1]:
		tmp+=1
	else:
		a.append(tmp)
		tmp=1
a.append(tmp)

b=[]
if s[0]=='0':
	m=2*k
else:
	m=2*k+1
for i in range(len(a)-k):
	b.append(sum(a[i:i+m]))
print(max(b))

Fixed submission:
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)
if s[-1]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
_max=0
i=len(a)-1
if i- m<0:
	print(n)
else:
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		m=t-m
		i-=1
	if a[i]>_max:
		_max=a[i]
	print(_max)