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