#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<int, int> mpa, mpb;
priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pque;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N, x;
  cin >> N >> x;
  int ans = 0;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a + N);
  ll cnt = 0;
  bool flag = true;
  for (int i = 0; i < N; i++) {
    cnt += a[i];
    if (cnt > x) {
      ans = i;
      break;
    }
  }
  if (flag) {
    cout << N << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
