#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, x;
  cin >> N >> x;
  long *a = new long[N];
  for (long i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a + N);
  long res = 0;
  for (long i = 0; i < N; i++) {
    if (x <= 0) {
      break;
    }
    x -= a[i];
    res++;
  }
  if (x != 0) {
    res--;
  }
  cout << res << endl;
}
