#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;
long long N, X, arr[MAX];
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> X;
  for (int A = 1; A <= N; A++) cin >> arr[A];
  sort(arr + 1, arr + N + 1);
  for (int A = 2; A <= N; A++) arr[A] += arr[A - 1];
  if (arr[N] == X) return cout << N, 0;
  for (int A = N - 1; A >= 1; A--)
    if (arr[A] <= X) return cout << A, 0;
  return 0;
}
