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