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