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