#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
const long long oo = 1e9;
long long n, maxn;
long long a[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> maxn;
  for (long long i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  long long cnt = 0;
  for (long long i = 1; i <= n; ++i) {
    if (maxn >= a[i]) cnt++, maxn -= a[i];
  }
  if (maxn > 0 && cnt > 0) cnt--;
  cout << cnt;
}
