#include <bits/stdc++.h>
using namespace std;
struct _OMAZINAI_ {
  _OMAZINAI_() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
  }
} __omazinai_instance__;
void _INPUT_IMPL_(){};
template <class T, class... Args>
void _INPUT_IMPL_(T& dest, Args&... args) {
  cin >> dest;
  _INPUT_IMPL_(args...);
}
void _OUTPUT_IMPL_(){};
template <class T, class... Args>
void _OUTPUT_IMPL_(T dest, Args... args) {
  cout << dest << (sizeof...(Args) ? " " : "");
  _OUTPUT_IMPL_(args...);
}
int cnt;
int main() {
  int N, x;
  _INPUT_IMPL_(N, x);
  vector<int> a(N);
  for (long long int(i) = 0; (i) < (N); ++(i)) cin >> a[i];
  ;
  std::sort(a.begin(), a.end());
  for (long long int(i) = 0; (i) < (N); ++(i))
    if ((x -= a[i]) >= 0) ++cnt;
  if (x > 0) --cnt;
  (_OUTPUT_IMPL_(cnt), std::cout << std::endl);
}
