#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  double x;
  int n;
  cin >> n >>x;
  int a[n];
  int m;
  for(int i=0;i<n;i++)
  {
    cin >> m;
    a[i]=m;
  }
  sort(a,a+n);
  int count=0;
  for(int i=0;i<n;i++)
  {
    x=x-a[i];
    if(x>=0){count++;}
  }
  if(x>0){count--;}
  cout<< count <<endl;
}