#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, x;
  cin >> N >> x;
  ll A[N];
  for (int i = 0; i < (N); ++i) cin >> A[i];
  sort(A + 0, A + N);
  ll sum[N + 1];
  sum[0] = 0;
  for (int i = 0; i < (N); ++i) sum[i + 1] = sum[i] + A[i];
  auto it = upper_bound(sum + 0, sum + N + 1, x);
  if ((int)(it - sum) == 1)
    cout << 0 << endl;
  else if (*(it - 1) == x)
    cout << (int)(it - sum) - 1 << endl;
  else
    cout << (int)(it - sum) - 2 << endl;
  return 0;
}
