#include<stdio.h>
#include<stdlib.h>
///*
void sort_N(long long int *x,long long int n);

int main() {

	int i, n, *ary;
  	long long int x;
	int counter=0;

	scanf_s("%d", &n);
	scanf_s("%lld", &x);

	ary = (long long int*)calloc(n, sizeof(long long int));
	if (ary == NULL) {
		return 0;
	}

	for (i = 0; i < n; i++) {
		scanf_s("%lld", &ary[i]);
	}

	sort_N(ary, n);

	for (i = 0; i < n; i++) {
		if (x >= ary[i]) {
			x -= ary[i];
			counter++;
		}
		else {
			break;
		}
	}

	/*
	for (i = 0; i < n; i++) {
		printf("%d ", ary[i]);
	}
	printf("\n");
	*/

	printf("%d\n", counter);

	free(ary);

	return 0;
}

void sort_N(int *x,int n) {

	int i,j,fake;

	for (i = 0; i < n - 1; i++) {
		for (j = 0; j < n - 1;j++){
			if (x[j] > x[j + 1]) {
				fake = x[j];
				x[j] = x[j + 1];
				x[j + 1] = fake;
			}
		}
	}
}

//*/