#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, A[N];
  cin >> N >> x;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A + N);
  int ans = 0, n = x, j = 0;
  while (n > 0) {
    n = n - A[j];
    if (n >= 0) ans++;
    j++;
  }
  cout << ans << endl;
}
