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