#include <cstdio>
#include <algorithm>

int a[104];

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