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

int main() {
	int a,b;
	cin >> a >> b;
	int c[a];
	for (int i = 0;i < a;i++) {
		cin >> c[i];
	}
	sort(c,c+i);
	int ans = 0;
	int sum = 0;
	for (int i = 0;i < a;i++) {
		if (sum+c[i] <= b) {ans++;}
		else {break;}
	}
	cout << ans << endl;
}