#include<iostream>
#include<algorithm>

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 i=0;
  while(x>=a[i]){
    x-=a[i];
    i++;
  }
  cout<<i<<endl;
}