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