#include <cstdio>
#include <algorithm>
using namespace std;
int a[110];
int main() {
	int n, x;
	scanf("%d%d", &n, &x);
	for(int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
	sort(a+1, a+n+1);
	int ans = 0;
	for(int i = 1; i < n; i ++ ) {
		if(a[i] <= x) x -= a[i], ans ++;
		else break;
	}
	ans += x == a[n];
	printf("%d\n", ans);
}