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