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

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