#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, x, k = 0, j = 0;
  cin >> n >> x;
  vector<long> v(n);
  for (int i = 0; i < n; i++) cin >> v.at(i);
  sort(v.begin(), v.end());
  while (x >= 0) {
    x -= v.at(j);
    if (x >= 0) {
      k++;
    }
    j++;
    if (j == n - 1) break;
  }
  cout << k << endl;
  return 0;
}
