#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, x;
  cin >> n >> x;
  long long a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  long long count = 0;
  for (i = 0; i < n; i++) {
    cout << x << "\n";
    if (x >= a[i]) {
      x -= a[i];
      count++;
    } else {
      break;
    }
  }
  if (x != 0) {
    if (count != 0) count--;
  }
  cout << count;
}
