#include<bits/stdc++.h>
using namespace std;
#define RI register int
int n,x,ans,a[105];
int main()
{
	scanf("%d%d",&n,&x);
	for(RI i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(RI i=1;i<n;++i)
		if(x>=a[i]) x-=a[i],++ans;
	if(x==a[n]) ++ans;
	printf("%d\n",ans);
	return 0;
}