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