#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
#define allSum(a) accumulate(a.begin(),a.end(),0)
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  int n,x;
  cin>>n>>x;
  vint a(n);
  rep(i,n)cin>>a[i];
  SORT(a);
  if(x==allSum(a)){
    cout<<n<<endl;
    return 0;
  }
  int sum=0;
  rep(i,n){
    sum+=a[i];
    if(x<sum){
      if(x==m)i--;
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<n-1<<endl;

  return 0;
}

