#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x;
  cin >> n >> x;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  ;
  long long s[n + 1];
  s[0] = 0;
  for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
  int ans = 0;
  while (s[ans + 1] <= x) ans++;
  cout << ans << endl;
}
