#include <bits/stdc++.h>
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (k < a[i]) {
      cout << i + 1;
      return 0;
    }
    k -= a[i];
  }
  if (k)
    cout << n - 1;
  else
    cout << n;
}
