#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long int to, cost;
};
const long long int INF = 1e18;
const long long int MOD = 1e9 + 7;
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  long long int len = v.size();
  s << "[";
  for (long long int i = 0; i < len; i++) {
    s << v[i];
    if (i < len - 1) s << " ";
  }
  s << "]";
  return s;
}
signed main() {
  long long int N, x;
  cin >> N >> x;
  vector<long long int> a(N);
  for (long long int i = (0); i < (N); ++i) {
    cin >> a[i];
  }
  sort((a).begin(), (a).end());
  long long int ans = 0;
  for (long long int i = (0); i < (N); ++i) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
