#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < N; i++) {
    cout << a[i] << endl;
  }
  vector<int> sum(N);
  sum[0] = a[0];
  if (sum[0] > x) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i < N; i++) {
    sum[i] += sum[i - 1] + a[i];
    if (sum[i] > x) {
      cout << i << endl;
      return 0;
    }
  }
  if (sum[N - 1] == x) {
    cout << N << endl;
  } else {
    cout << N - 1 << endl;
  }
  return 0;
}
