#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long n, x;
  cin >> n >> x;
  vector<long> a(n);
  long sum = 0;
  long ans = 0;
  long t = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());
  if (sum == x) {
    cout << n << endl;
  } else if (sum < x) {
    cout << n - 1 << endl;
  } else {
    while (t < x && ans < n) {
      t += a[ans];
      ans++;
    }
    cout << ans - 1 << endl;
  }
}
