#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	long i=0,n,x,a[114];
	for(cin>>n>>x;i<n;cin>>a[i++]);
	sort(a,a+n);
	for(i=0;x>0&&i<n;i++)x-=a[i];
	cout<<i-1+(x==0)<<endl;
}