#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, ck = 0, ans;
  cin >> n >> x;
  long long arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  long long total = 0;
  for (int i = 0; i < n; i++) {
    total += arr[i];
    if (total > x) {
      ck = 1;
      ans = i;
      break;
    }
  }
  if (ck)
    cout << ans << endl;
  else
    cout << n << endl;
  return 0;
}
