#include<cstdio>
#include<algorithm>
using namespace std;

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