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