#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
inline int get();
int n,m;
long long ans=1;
int N[20001];
int main()
{
freopen("shelf.in","r",stdin);
freopen("shelf.out","w",stdout);
n=get(),m=get();
for(int i=1;i<=n;i++)N[i]=get();
sort(N+1,N+n+1,greater<int>());
for(long long i=0;i<m;ans++)i+=N[ans];
printf("%lld",ans-1);
return 0;
}
inline int get()
{
int t=0;char c=getchar(),j=1;
while(!isdigit(c))
if(c=='-')j=-1,c=getchar();
else c=getchar();
while(isdigit(c))
t=(t<<3)+(t<<1)+c-'0',
c=getchar();
return j*t;
}