#include <bits/stdc++.h>
using namespace std;
string yn(bool x) { return x ? "Yes" : "No"; }
int main() {
  int n, p;
  cin >> n >> p;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int sum = 0;
  for (int i = 0; i < n; i++) sum += a[i];
  if (sum < p) {
    cout << n - 1 << endl;
    return 0;
  }
  int ans = 0;
  int k = 0;
  while (p > 0) {
    p -= a[k];
    if (p >= 0) ans++;
    k++;
  }
  cout << ans << endl;
}
