#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

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