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