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