#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX=100+10;
int main()
{	
	int n,a[MAX],x,ans;
	cin>>n>>x;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		if(x>=a[i])
			x-=a[i],ans++;
	if(x&&ans==n)
		ans--;
	cout<<ans<<endl;
	return 0;
}
//???