#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, first;
  cin >> n >> first;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort((a).begin(), (a).end());
  long long sum = 0;
  for (auto el : a) sum += el;
  if (sum == first) {
    cout << n;
    return 0;
  }
  int pos = 0;
  sum = 0;
  while (pos < n - 1 && sum + a[pos] <= first) sum += a[pos++];
  cout << pos;
  return 0;
}
