#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
void printVector(vector<long long> A) {
  cout << "[vector]" << endl;
  for (int i = 0; i < A.size(); i++) {
    cout << A[i] << " ";
  }
  cout << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, x;
  cin >> N >> x;
  vector<long long> a(N);
  for (int i = (0); i < (N); ++i) cin >> a[i];
  sort((a).begin(), (a).end());
  long long childSweetSum = accumulate((a).begin(), (a).end(), 0LL);
  long long sweetNum = x;
  if (sweetNum > childSweetSum) {
    cout << (N - 1) << endl;
  } else if (sweetNum == childSweetSum) {
    cout << (N) << endl;
  } else {
    if (sweetNum < a[0]) {
      cout << (0) << endl;
      return 0;
    }
    long long currentSweetSum = 0;
    for (int i = (0); i < (N); ++i) {
      currentSweetSum += a[i];
      if (currentSweetSum == sweetNum) {
        cout << (i + 1) << endl;
        return 0;
      } else if (currentSweetSum < sweetNum) {
        cout << (i) << endl;
        return 0;
      }
    }
  }
  return 0;
}
