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