#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long N, x;
  cin >> N >> x;
  vector<long long> a(N);
  for (long long i = 0, i_len = (N); i < i_len; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  long long ans = 0;
  for (long long i = 0, i_len = (N); i < i_len; ++i) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    } else {
      break;
    }
  }
  if (ans > 0 && x > 0) ans--;
  cout << ans << endl;
  return 0;
}
