#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<ll> a(N);
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll sum = accumulate(a.begin(), a.end(), 0);
  const auto minimum = *min_element(a.begin(), a.end());
  ll count = 0;
  if (sum == x) {
    count = N;
  } else if (x < minimum) {
    count = 0;
  } else if (sum > x) {
    int su = 0;
    for (ll i = 0; i < N; i++) {
      if (su < x) {
        su += a[i];
        count++;
      } else {
        break;
      }
    }
  } else if (sum < x) {
    count = N - 1;
  }
  cout << count << endl;
}
