#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, x;
  cin >> N >> x;
  vector<long long> line(N);
  for (int i = 0; i < N; i++) {
    cin >> line[i];
  }
  sort(line.begin(), line.end());
  long long pre = 0;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (pre + line[i] <= x) {
      pre += line[i];
      ans++;
    }
  }
  cout << ans << endl;
}
