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