#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000000;
double PI = 3.1415926535;
template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
int main() {
  long long 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 cnt = 0;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] + cnt <= X) {
      ans++;
      cnt += A[i];
      if (X - cnt < A[i] && X != cnt) {
        ans--;
      }
    }
  }
  cout << ans << endl;
}
