#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, x, result{};
  cin >> N >> x;
  vector<long long> a(N);
  for (long long i{}, tmp; i < N; ++i) {
    cin >> tmp;
    a[i] = tmp;
  }
  sort(begin(a), end(a));
  for (auto i : a) {
    x -= i;
    if (x < 0) break;
    result++;
  }
  std::cout << result << std::endl;
}
