#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll solve() {
  ll N, X;
  cin >> N >> X;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (X >= A[i]) {
      X -= A[i];
      ans++;
    }
  }
  return ans;
}
int main() {
  auto ans = solve();
  cout << ans << "\n";
  return 0;
}
