#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N, x;
  cin >> N >> x;
  vector<int> a(N + 1, 0);
  for (int i = 1; i <= N; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<long long> csum(N + 1, 0LL);
  for (int i = 1; i <= N; ++i) {
    csum[i] = csum[i - 1] + (long long)a[i];
  }
  int ind1 = lower_bound(csum.begin(), csum.end(), (long long)x) - csum.begin();
  int ind2 = upper_bound(csum.begin(), csum.end(), (long long)x) - csum.begin();
  int res = 0;
  if (ind1 != ind2) {
    res = ind1;
  } else {
    res = max(0, ind1 - 2);
  }
  cout << res << endl;
  return 0;
}
