#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x;
  cin >> n >> x;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n, greater<int>());
  long long count = 0;
  for (long long i = 0; i < n; i++) {
    if (x - a[i] >= 0) {
      x -= a[i];
      count++;
    }
  }
  if (x == 0 || count == 0)
    cout << count;
  else
    cout << count - 1;
}
