#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, x, ans = 0;
  cin >> n >> x;
  long arr[n];
  for (long i = 0; i < n; ++i) cin >> arr[i];
  sort(arr, arr + n);
  for (auto i : arr) {
    if (i <= x) {
      x -= i;
      ans++;
    } else
      break;
  }
  if (x > 0 and ans > 0) ans--;
  cout << ans << "\n";
}
