#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long x;
  vector<long long> v;
  cin >> N >> x;
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    v.push_back(num);
  }
  sort(v.begin(), v.end());
  int rest = x;
  int num = 0;
  for (auto it = v.begin(); it != v.end(); it++) {
    if (rest >= *it) {
      rest -= *it;
      num++;
    }
    cout << *it << endl;
  }
  if (rest > 0 && num == N) {
    num--;
  }
  cout << num << endl;
}
