#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long int x;
  cin >> N >> x;
  long int count = 0;
  vector<long int> a(N);
  long int answer = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < N; i++) {
    if (count + a[i] <= x) {
      answer += 1;
      count += a[i];
    }
  }
  cout << answer;
  return 0;
}
