#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, x, 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++;
    } else
      break;
  }
  cout << ans << endl;
  return 0;
}
