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