#include <bits/stdc++.h>
using namespace std;

int a[110];

int main() {
	int n,x;
	cin >> n >> x;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a,a+n);
	int ans = 0;
	for (int i = 0; i < n; i++) if (a[i] <= x) {
		ans++;
		x -= a[i];
	}
	if (ans == n && x > 0) ans--;
	cout << ans << "\n";
}