#include <bits/stdc++.h>
using namespace std;
int n;
long long x;
long long a[105];
int main() {
  int cnt = 0, j = 0;
  int cn = 0, jj = 1;
  cin >> n >> x;
  ;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  while (x - a[j] >= 0 && j < n) {
    x = x - a[j];
    cnt++;
    j++;
  }
  while (x - a[n - jj] <= 0 && jj < n) {
    x = x - a[n - jj];
    cn++;
    jj++;
  }
  if (x > 0 && cn > 0) cn = cn - 1;
  if (x > 0 && cnt > 0) cnt = cnt - 1;
  cnt = min(cn, cnt);
  cout << cnt;
  return 0;
}
