#include <bits/stdc++.h>
using namespace std;
inline void solve() {
  long long n, x, ans = 0;
  cin >> n >> x;
  long long a[n];
  for (long long &i : a) cin >> i;
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    if (x >= a[i]) ans++, x -= a[i];
  }
  if (x and ans) ans--;
  cout << ans << endl;
}
signed main() {
  long long n = 1;
  while (n--) solve();
  return 0;
}
