#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 ans = 0;
  int i = 0;
  while (p > 0) {
    if (p > 0 && i == n - 1) break;
    ans++;
    p -= a[i];
    i++;
  }
  cout << ans << endl;
}
