#include<cstdio>
#include<vector>
#include<utility>
#define v it->first
#define t it->second
using namespace std;
vector<pair<int,int> >S;
void read(),solve();
int i,n,V[200020],maxim,d,curr,j,cnt,a;
int main()
{
	read();
	solve();
	return 0;
}
void read()
{
	freopen("obstacole.in","r",stdin);
	freopen("obstacole.out","w",stdout);
	scanf("%d%d",&n,&d);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a){++curr;if(V[i-1])S.push_back(make_pair(V[i-1],i-1));}
		else
		{
			V[i]=V[i-1]+1;
			maxim=maxim>curr?maxim:curr;curr=0;
		}
	}
	maxim=maxim>curr?maxim:curr;
	S.push_back(make_pair(200010,n+200010));
}
void solve()
{
	if(maxim>d){printf("0\n");return;}
	for(vector<pair<int,int> >::iterator it=S.begin();it!=S.end();it++)
	{
		if(t-v-d<0)continue;
		maxim=0;
		for(vector<pair<int,int> >::iterator it1=it-1;it>=S.begin()&&(t-v-d)<=(it1->second);it1--)maxim=maxim>(it1->first)?maxim:(it1->first);
		maxim=maxim>v?v:maxim;
		(it->first)=maxim;
	}
	vector<pair<int,int> >::iterator it=S.end()-1;
	printf("%d\n",v);
}