#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long x;
  cin >> x;
  vector<long> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int answer = 0;
  long ruisekiwa = 0;
  while (ruisekiwa < x && answer < N) {
    ruisekiwa += a[answer];
    answer++;
  }
  cout << answer << endl;
}
