#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,i,a[105],ans=0;
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++)
	{
		if(m>=a[i])
		{
			ans++;
			m-=a[i];
		}
	}
	if(ans==n&&m>0)ans--;
	printf("%d\n",ans);
	return 0;
} 