#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];
  if (sum[1] > x)
    cout << "0\n";
  else if (sum[N + 1] < x)
    cout << N - 1 << endl;
  else {
    auto it = upper_bound(sum + 0, sum + N + 1, x);
    if (*(it - 1) == x)
      cout << (int)(it - sum) - 1 << endl;
    else
      cout << (int)(it - sum) << endl;
  }
  return 0;
}
