#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
const long long INF = 1ll << 60;
int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  ll nokori = x;
  for (int i = 0; i < (int)(n); i++) {
    ll want = a[i];
    if (nokori >= want) {
      ans++;
      nokori -= want;
    }
  }
  cout << ans << endl;
  return 0;
}
