#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  ll i, j;
  ll sum = 0;
  for (i = 0; i < n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  sort(a.begin(), a.end());
  ll nin;
  if (x < a.at(0)) {
    cout << 0 << endl;
    return 0;
  }
  if (x <= sum) {
    nin = 0;
    i = 0;
    while (x > 0) {
      nin++;
      x -= a.at(i);
      i++;
    }
  } else
    nin = n - 1;
  cout << nin << endl;
  return 0;
}
