#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, dis = 0, i = 0, ans = 0;
  int a[N];
  cin >> N >> x;
  for (int k = 0; k < N; k++) {
    cin >> a[k];
  }
  sort(a, a + N);
  if (x >= a[0]) {
    while (dis < x && i < N) {
      dis += a[i];
      i++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
