#include <bits/stdc++.h>
using namespace std;
int s[110];
int main() {
	
	int n, x; scanf("%d%d", &n, &x);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &s[i]);
	sort(s + 1, s + n + 1);
	int Ans = 0;
	for (int i = 1; i <= n; ++i)
		if (x >= s[i]) {
			Ans ++;
			x -= s[i];
		}
	if (x && Ans == n) Ans --;
	cout << Ans << endl;

}