#include <bits/stdc++.h>
using namespace std;
int ketasum(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int count = 0;
  int rest = x;
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < n - 1; i++) {
    rest = x -= a[i];
    if (rest < 0) break;
    count++;
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  if (sum == x) count++;
  cout << count << endl;
}
