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