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