#include<cstdio>
#include<algorithm>
int a[100000];
int main()
{
int n,t,i;
scanf("%d%d",&n,&t);
for(i=0;i<n;i++)scanf("%d",a+i);
std::sort(a,a+n);
for(i=0;i<n&&t>0;i++)t-=a[i];
if(i==n)printf("%d\n",t?n-1:n);
else printf("%d\n",t?i-1:i);
}