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