#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, ans = 0;
  cin >> n >> x;
  vector<unsigned long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) a[i + 1] += a[i];
  auto itr = lower_bound(a.begin(), a.end(), x);
  ans = distance(a.begin(), itr) - (*itr != x ? 1 : -1);
  cout << (ans > 0 ? ans : 0) << endl;
  return 0;
}
