#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n), s(n + 1);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) s[i + 1] += s[i] + a[i];
  int lo = 0, hi = n + 1;
  while (hi - lo > 1) {
    int mid = lo + (hi - lo) / 2;
    if (s[mid] <= x)
      lo = mid;
    else
      hi = mid;
  }
  if (lo == n && s[n] != x) lo--;
  cout << lo << endl;
  return 0;
}
