#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 105
using namespace std;

int n, x, a[N];
int main()
{
	int i;
	cin >> n >> x;
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a + n);
	for (i = 0; i < n && x >= a[i]; x -= a[i], i++);
    cout << i - (x > a[i]) << endl;
    return 0;
}