#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N,x;
  cin >> N >> x;


  int a[N] = {};
  for(int i = 0; i < N; i++)
  {
    /* code */
    cin >> a[i];
  }
  sort(a,a+N);

  int res = 0;
  for(int i = 0; i < N; i++)
  {
    //cout << a[i] << endl;
    /* code */
    x = x - a[i];
    if(x >= 0){
      //cout << "x:" << x <<endl;
      res++;
    }

  }
  if(x > 0){
    res--;
  }
  cout << res << endl;

}