#include <bits/stdc++.h>
int main() {
  int n, x;
  std::cin >> n >> x;
  std::vector<int> a(n);
  for (auto& an : a) {
    std::cin >> an;
  }
  std::sort(std::begin(a), std::end(a));
  int result = 0;
  for (result = 0; result < n; ++result) {
    if (a[result] <= x) {
      x -= a[result];
    } else {
      break;
    }
  }
  std::cout << result << std::endl;
  return 0;
}
