#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x, a[101];
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int d, cnt = 0;
  for (int i = n - 1; i > 0; i--) {
    if (x >= a[i]) cnt++, x = x - a[i];
  }
  if (x == a[0]) cnt++;
  cout << cnt << '\n';
  return 0;
}
