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