#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  int N, x;
  std::cin >> N >> x;
  std::vector<int> a(N);
  for (size_t i = 0; i < N; i++) {
    std::cin >> a[i];
  }
  std::sort(a.begin(), a.end());
  int ans = 0;
  int ac[N + 1];
  ac[0] = 0;
  for (size_t i = 0; i < N; i++) {
    ac[i + 1] = ac[i] + a[i];
    if (ac[i + 1] <= x) {
      ans = i + 1;
    }
  }
  if (ans == N && x > ac[N]) {
    ans += -1;
  }
  std::cout << ans << '\n';
  return 0;
}
