#include <bits/stdc++.h>
using namespace std;
signed main() {
  int a, b = 0, e = 0, f = 0;
  int c, d[1000000];
  cin >> a >> c;
  for (int i = 0; i < a; i++) {
    cin >> d[i];
    b += d[i];
  }
  if (b <= c)
    cout << a;
  else {
    sort(d, d + a);
    while (true) {
      if (c - d[e] < 0) break;
      c -= d[e];
      e++;
      f++;
    }
    cout << f;
  }
  cout << "\n";
}
