#include<iostream>
using namespace std;
int main() {
	int n, x;
	int a[110];
	__int64 aa = 0;
	int b;
	cin >> n;
	cin >> x;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		aa += a[i];
	}
	if (aa == x) {
		cout << n << endl;
	}
	else if (aa < x) {
		cout << n - 1 << endl;
	}
	else {
		for (int i = 0;i < n - 1;i++) {
			if (a[i] > a[i + 1]) {
				b = a[i];
				a[i] = a[i + 1];
				a[i + 1] = b;
				i -= 2;
				if (i < -1) {
					i = -1;
				}
			}
		}
		aa = 0;
		for (int i = 0;i < n;i++) {
			aa += a[i];
			if (aa > x) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}