#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  ;
  for (ll i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  ll count = 0;
  ;
  for (ll i = 0; i < n; ++i) {
    if (x < a[i])
      break;
    else {
      x -= a[count];
      ++count;
    }
  }
  cout << count << endl;
  return 0;
}
