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