#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, x;
  cin >> N >> x;
  vector<int64_t> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  int count = 0;
  int64_t acount = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < N; i++) {
    acount += a.at(i);
    if (acount > x) {
      acount -= a.at(i);
      break;
    }
    count++;
  }
  cout << count;
}
