#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(void) {
  ll N, x;
  ll count = 0;
  vector<ll> A;
  cin >> N >> x;
  A.resize(N);
  for (ll i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  for (auto &i : A) {
    if (x < 0) break;
    if (x < i) {
      count--;
      break;
    }
    x -= i;
    count++;
  }
  cout << count << endl;
  return 0;
}
