#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int n,x;
  cin >> n >> x;
  int a[n];
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int b[n];
  b[0]=a[0];
  for (int i=1;i<n;i++){
    b[i]=b[i-1]+a[i];
  }
  int ans=0;
  for (int i=0;i<n;i++){
    if(b[i]<=x){
      ans=min(ans,i+1)
    }
  }
  cout << ans << endl;
}
    