#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define  epsiron 1e-2
typedef long long ll;

using namespace std;
int main(void){
  ll n,x;
  ll an[n];
  cin >> n >> x;
  for(ll i=0;i<n;++i){
     cin >>an[i]; 
  }
  std::sort(an,an+n);
  ll sum=0;
  for(int i=0;i<n && ;++i){
    sum += a[i];
    if(sum>x &&i<n-1){
       cout << i;
    }
    if(i==n-1&&sum==x){
      cout << n;
    }
    if(i==n-1&&sum>x){
      cout << n-1;
    }
  }
return 0;
}
