#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
int main() {
  int N;
  ll x;
  cin >> N >> x;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (x < 0) {
      break;
    } else if (A[i] <= x) {
      x -= A[i];
      ans++;
    }
  }
  if (x == 0) {
    cout << ans << endl;
  } else if ((ans == 0) && (x > 0)) {
    cout << 0 << endl;
  } else {
    cout << ans - 1 << endl;
  }
  return 0;
}
