#include<bits/stdc++.h>
using namespace std;

int n,x;
int a[210];
int main()
{
	scanf("%d%d",&n,&x);
	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 (a[i]<=x)	x-=a[i],ans++;
		else {x=-1;ans++;break;}
	}
	if (x!=0)	ans--;
	printf("%d\n",ans);
	return 0;
}