#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,a[2000000];
int h=0;
long long cost=0;
int sum=0,msum=0;
int main()
{
freopen("tickets.in","r",stdin);
freopen("tickets.out","w",stdout);
cin>>n>>m;
for (int i=1;i<=n;++i)
{
scanf("%d",&a[i]);
if (cost+a[i]<=m)
{
cost+=a[i];
if (h==0) h=i;
sum++;
if (sum>msum) msum=sum;
}
else if (cost+a[i]>m)
{
while (true)
{
cost-=a[h];
h++;
sum--;
if (h==i) break;
if (cost+a[i]<=m) break;
}
cost+=a[i];
sum++;
}
}
cout<<msum;
return 0;
}