#include <bits/stdc++.h>
#define N_MAX 100
int n, x, a[N_MAX], i, m;
int main()
{
	scanf("%d %d", &n, &x);
	for (i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	std::sort(a, a + n);
	for (i = 0; i < n - 1 && x >= a[i]; ++i)
		x -= a[i], ++m;
	m += x == a[n - 1];
	printf("%d\n", m);
	return 0;
}