#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;
int main() {
  int n, x;
  cin >> n >> x;
  V<int> a(n);
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int left = x;
  int count = 0;
  int i = 0;
  while (left > 0 && i < n) {
    left -= a[i++];
    if (left >= 0) {
      count++;
    }
  }
  cout << count << endl;
}
