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