#include<bits/stdc++.h>
using namespace std;
int n ,  a[101] , x;
int main()
{
    cin >> n >> x;
    for(int i = 1 ; i <= n ; ++i)
        cin >> a[i];
    sort(a + 1 , a + n + 1);
    int cnt = 0;
    for(int i = 1 ; i <= n ; ++i)
        if(a[i] <= x)x -= a[i] , ++cnt;
    if(x > 0 && cnt == n)--cnt;
    cout << cnt;
}
