#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,x,ans;
  cin>>N>>x;
  int a[N],b[N];
  for(int i = 0;i<N;i++){
    cin >> a[i];
    b[i] += a[i];
  }
  if(b[N] == x){
    ans = N;
  }
  if(b[N] > x){
    ans = N-1;
  }
  else{
    sort(a.begin,a.end());
    int sum = 0;
    int count = 0;
    for(int k = 0;k<N;k++){
      sum = sum + a[k];
      count++;
      if(sum > x){
        ans = count;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
        
    
  