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