#include <bits/stdc++.h>
int main() {
  int n, x;
  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());
  int nofc;
  for (int i = 0; i < n; ++i) {
    if (a.at(i) > x) {
      nofc = i;
      break;
    }
    x -= a.at(i);
    nofc = i + 1;
  }
  if (x > 0 && nofc != 0) --nofc;
  std::cout << nofc << std::endl;
  return 0;
}
