#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost;
};
long long a[101];
signed main() {
  long long n, x;
  cin >> n >> x;
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long ans = 0;
  for (long long i = n - 1; i >= 0; i--) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    }
  }
  if (x && ans == n) ans--;
  cout << ans << endl;
}
