#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;
  while (cnt <= n) {
    if (m - arr[cnt] >= 0) {
      m -= arr[cnt];
      cnt++;
    } else
      break;
  }
  if (m > 0) cnt = max(cnt - 1, 0);
  cout << cnt << endl;
}
