#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  ll x;
  cin >> x;
  ll a[n];
  ll cnt = 0;
  ll sum = 0;
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  if (sum <= x) {
    cnt = n;
  } else {
    for (ll i = 0; i < n; i++) {
      if (a[i] <= x) {
        if (i == n - 1 && a[i] < x) {
        } else {
          cnt++;
          x -= a[i];
        }
      }
    }
  }
  cout << cnt << endl;
}
