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