#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  int cnt = 0, ans = 0;
  while (cnt < n) {
    if (m - arr[cnt] >= 0) {
      m -= arr[cnt];
      ans++;
    }
    cnt++;
  }
  if (m && arr[n - 1] < m) ans = max(ans - 1, 0);
  cout << ans << endl;
}
