#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long x;
  cin >> N >> x;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  int ans = 0;
  long long cost = 0;
  for (int i = 0; i < N; i++) {
    ans++;
    cost += a[i];
    if (cost > x) {
      ans--;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
