#include <bits/stdc++.h>
using namespace std;
long long d1[4] = {1, -1, 0, 0};
long long d2[4] = {0, 0, 1, -1};
int main() {
  long long n, x;
  cin >> n >> x;
  long long ans = 0;
  vector<long long> a(n);
  for (long long i = (0); i < (long long)(n); i++) {
    cin >> a[i];
  }
  sort((a).begin(), (a).end());
  for (long long i = (0); i < (long long)(n); i++) {
    if (a[i] <= x) {
      ans++;
      x -= a[i];
    }
  }
  cout << ans << endl;
  return 0;
}
