#include <iostream>
using namespace std;
int main()
{
int i,j,N,tall;
int head,tail,sum,ans;
int pre,next;
sum=0;ans=0;
cin>>N>>tall;
int cow[N][3];
cin>>cow[0][0];
cow[0][1]=-1;
cow[0][2]=-1;
head=0;
for(i=1;i<N;i++){
cin>>cow[i][0];
if(cow[i][0]>=cow[head][0]){
cow[head][1]=i;
cow[i][1]=-1;
cow[i][2]=head;
head=i;
}else{
pre=head;
next=cow[pre][2];
while(next!=-1 and cow[i][0]<cow[next][0]){
pre=next;
next=cow[pre][2];
}
cow[i][1]=pre;
cow[i][2]=next;
cow[pre][2]=i;
cow[next][1]=i;
}
}
cout<<endl;
while(head!=-1){
sum=sum+cow[head][0];
ans+=1;
head=cow[head][2];
if(sum>=tall){
cout<<ans<<endl;
return 0;
}
}
return 0;
}