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

int n, x;
int a[101];
int ans = 0;

void saiki(int inow, int total, int kubatta) {
	if ( total > x) {
		return;
	}
	else {
		if (n == inow) {
			if (total <= x) {
				ans = max(ans, kubatta);
		}
		else {
			saiki(inow + 1, total + a[inow], kubatta + 1);
			saiki(inow + 1, total, kubatta);
		}
	}
	return;
}

int main()
{

	int i;
	cin >> n >> x;

	for (i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a, a + n);

	saiki(0, 0, 0);

	cout << ans << endl;
	return 0;
}
