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