#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n, x, a[105];
#define gc ch = getchar()
inline int re(){
	char ch = getchar(); int x = 0, f = 1;
	for (; !isdigit(ch); gc) if (ch == '-') f = -1;
	for (; isdigit(ch); gc) x=  x * 10 + ch - '0';
	return x * f;  
}
#undef gc
int main(){
	n = re(); x = re();
	for (int i = 1; i <= n; i++) a[i] = re();
	sort(a + 1, a + 1 + n);
	int cnt = 0;
	for (int i = 1; i <= n; i++){
		if (x >= a[i]){
			x -= a[i]; cnt++;
			if (cnt == n && x > 0) z--;
		}	
		else break;
	}
	printf("%d\n", cnt);
	return 0;
} 