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