#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  sort(ar, ar + n);
  int cnt = 0;
  int in = 0;
  while (m && in < n) {
    m -= ar[in];
    in++;
    cnt++;
  }
  if (m > 0) {
    cnt--;
  }
  cout << cnt << endl;
  return 0;
}
