#include<bits/stdc++.h>

using namespace std;
using ll = long long;
int main(){
  ll n,x;
  cin >> n >> x;
  vector<ll>a(n);
  for(ll& t:a)cin >> t;
  sort(a.begin(),a.end());
  ll ret=0;
  for(ll& t:a){
    if(t<=x)ret++;
    x-=t;
  }
  if(x>0)ret--;
  cout << ret << endl;
  return 0;
}
