#include <cstdio>
#include <algorithm>

int n, a[101000], x;

int main()
{
	scanf("%d%d", &n, &x);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	std::sort(a + 1, a + n + 1);
	int ans = 0;
	for(int i = 1; i < n; i++)
	{
		if(x >= a[i]) x -= a[i], ans++;
	}
	if(x == a[n]) ans++;
	printf("%d\n", ans);
	return 0;
}