#include <bits/stdc++.h>
int main(void) {
  int N, x, ans = 0, total = 0;
  std::cin >> N >> x;
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> a.at(i);
  }
  std::sort(a.begin(), a.end());
  for (int i : a) {
    total += i;
    if (total > x) {
      break;
    } else {
      ++ans;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
