#include <bits/stdc++.h>
using namespace std;

///////////////////////////////////////////
const long long int INF = 1000000000000000000LL;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
///////////////////////////////////////////

int main(){
  ll n,x;
  cin>>n>>x;
  vi v;
  ll t;
  rep(i,n){
    cin>>t;
    v.pb(t);
  }
  ll ans=0;
  sort(all(v));
  for(int i=0;i<n;i++){
    if(x-v[i]>=0){
      ans++;
      x -= v[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}
