#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, ans = 0, cnt = 0, total = 0;
  cin >> n >> x;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    total += vec.at(i);
  }
  if (total < x) {
    cout << n - 1 << endl;
    return 0;
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    cnt += vec.at(i);
    if (cnt <= x)
      ans++;
    else
      break;
  }
  cout << ans << endl;
}
