#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,carry,t=0,pack,finish=0;
cin>>n>>carry;
int weapons[n];
for(int x=0;x<n;x++)
{
cin>>weapons[x];
}
pack=carry;
while(finish<n)
{
t++;
pack=carry;
for(int x=0;x<n;x++)
{
if(weapons[x]<pack)
{
pack-=weapons[x];
weapons[x]=0;
finish++;
}
}
}
cout<<t;
return 0;
}