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