#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
	int n,x;
	cin>>n>>x;
	vector<int> a(n);
	REP(i,n) cin>>a[i];
	
	sort(ALL(a));
	
	int cnt=0;
	REP(i,n){
		x-=a[i];
		cnt++;
		if(x<=0) break;
	}
	
	if(x==0) cout<<cnt<<endl;
	else cout<<cnt-1<<endl;
	return 0;
}