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