#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, sum, count;
  cin >> N >> x;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  sum = 0;
  int i = 0;
  while (sum < x) {
    sum += vec.at(i);
    cout << sum << endl;
    if (sum > x) break;
    if ((i == N - 1) && sum != x) break;
    i++;
  }
  cout << i << endl;
}
