#include <bits/stdc++.h>
using namespace std;
long long n, m, a[110], ans;
signed main() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    if (a[i] <= m) {
      ans++;
      m -= a[i];
    }
    if (m > 0 && i == n - 1 && ans == n - 1) {
      ans--;
    }
  }
  ans = max(ans, 0ll);
  cout << ans << endl;
  return 0;
}
