#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n,x;
cin >> n >> x;
ll a[n];
for(ll i=0;i<n;i++){
    cin >> a[i];
}
sort(a,a+n);
ll cnt=0;
ll sum=0;
for(ll i=0;i<n;i++){
if(sum+a[i]<=x){cnt++;}
sum+=a[i];
}
if(sum<x)cnt--;
cout << cnt << endl;
}
