#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double epsilon = 1e-9;
const int maxn = 1e6 + 10;
void solve() {
  long long int n, x;
  cin >> n >> x;
  vector<long long int> a(n);
  for (auto &i : a) cin >> i;
  sort(a.begin(), a.end());
  long long int i = 0, ct = 0;
  while (i < n && x >= a[i]) {
    x -= a[i];
    ct++;
    i++;
  }
  if (x > 0 && ct > 0 && i == n - 1) ct--;
  cout << ct;
}
int main() {
  int t = 1;
  while (t--) solve();
  cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
  return 0;
}
