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