#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, ans = 0, i = 0;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  if (x > accumulate(a.begin(), a.end(), 0)) {
    cout << n - 1 << endl;
    return 0;
  }
  sort(a.begin(), a.end());
  while (x >= a[i] && i < a.size()) x -= a[i++], ans++;
  cout << ans << endl;
  return 0;
}
