#include <bits/stdc++.h>
using namespace std;

int main(){
  int N,x;
  cin>>N>>x;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  int i;
  for(i=0;i<N;i++){
    if(x>=v[i])x-=v[i];
    else break;
  }
  int ans=i;
  if(i==N&&x!=0)ans--;
  cout<<ans<<endl;
}
