#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, sum, count;
  sum = 0;
  count = 0;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  sort((a).begin(), (a).end());
  while (sum <= x && count < n) {
    sum += a[count];
    count++;
  }
  if (sum < x) {
    count--;
  }
  cout << count << endl;
}
