#include <bits/stdc++.h>
int main() {
  int N, x, c = 0;
  std::vector<int> a;
  std::cin >> N >> x;
  for (int i = 0; i < N; ++i) {
    int y;
    std::cin >> y;
    a.push_back(y);
  }
  std::sort(a.begin(), a.end());
  for (int i = 0; i < N; ++i) {
    if (x >= a[i]) {
      ++c;
      x -= a[i];
    }
  }
  if (x > 0) c -= c == 0 ? 0 : 1;
  std::cout << c << std::endl;
  return 0;
}
