#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll INF = 100100100;
const ll MOD = (ll)1e9 + 7;
const double EPS = 1e-9;
ll dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
ll dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
signed main() {
  ios::sync_with_stdio(false);
  ll n, i;
  ll x;
  cin >> n >> x;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  sort((a).begin(), (a).end());
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    } else {
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}
