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

int main(){
  int N, x;
  cin >> N >> x;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    sum += vec.at(i);
  }
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    if (residue >= vec.at(i)){
      residue -= vec.at(i);
      count++;
    }
  }
  
  if (sum == x) {
    cout << N << endl;
  }
  else{
    cout << count << endl;
  }
  
  
}