#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[i];
  }
  int cnt = 0;
  std::sort(a.begin(), a.end());
  for (int i = 0; i < N; ++i) {
    x -= a[i];
    if (x <= 0) {
      cnt = i;
      break;
    }
  }
  std::cout << cnt << std::endl;
  return 0;
}
