#include <bits/stdc++.h>
int main() {
  int N;
  long long x;
  std::cin >> N >> x;
  std::vector<long long> a(N);
  for (int i = 0; i < N; ++i) std::cin >> a[i];
  std::sort(a.begin(), a.end());
  int happy = 0;
  long long sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += a[i];
    if (sum <= x)
      ++happy;
    else
      break;
  }
  if (sum < x) --happy;
  std::cout << happy << std::endl;
  return 0;
}
