#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n, x;
  long long an[n];
  cin >> n >> x;
  for (long long i = 0; i < n; ++i) {
    cin >> an[i];
  }
  std::sort(an, an + n);
  long long i = 0;
  while (x >= 0 && i <= n) {
    x -= an[i];
    if (x < 0) break;
    i++;
  }
  cout << i - 1;
  return 0;
}
