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