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