#include <iostream>
#include <algorithm>
using namespace std;

int N,x;
int main(){
	cin >> N >> x;
	int A[N+1];
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	sort(A,A+N);
	int ans = 0;
	for(int i=0;i<N-1;i++){
		if(x>=A[i]){
			ans++;
			x -= A[i];
		}
		if(x<A[i]) break;
	}
	if(x==A[N-1]) ans++;
	cout << ans << endl;
}