#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n,x;
  cin>>n>>x;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a.at(i);

  sort(a.begin(),a.end());

  int cnt=0;
  int ans;
  if(x>sum) ans=n-1;
  else if(x==sum) ans=n;
  else
  {
  for(int i=0;i<n;i++)
  {
    if(x>=a.at(i))
    {
      cnt++;
      x-=a.at(i);
    }
    else break;
  }
    ans=cnt;
  }

  cout<<ans<<endl;
}