#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = (1ll << 62) - 1;
signed main() {
  long long N, X;
  cin >> N >> X;
  vector<long long> A(N);
  for (long long i = (long long)(0); i < (long long)(N); i++) cin >> A[i];
  long long ans = N, sum = 0;
  sort((A).begin(), (A).end());
  for (long long i = (long long)(0); i < (long long)(N); i++) {
    sum += A[i];
    if (sum > X) {
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
}
