#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  long long temp;
  while (b > 0) {
    temp = a % b;
    a = b;
    b = temp;
  }
  return a;
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long fpow(long long b, long long exp, long long mod) {
  if (exp == 0) return 1;
  long long t = fpow(b, exp / 2, mod);
  if (exp & 1) return t * t % mod * b % mod;
  return t * t % mod;
}
long long divmod(long long i, long long j, long long mod) {
  i %= mod, j %= mod;
  return i * fpow(j, mod - 2, mod) % mod;
}
clock_t time_p = clock();
void TimeTaken() {
  time_p = clock() - time_p;
  cerr << "Completion time : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
void solve() {}
int main() {
  int n, ans = 0, sum = 0, x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = int(0); i <= int(n - 1); i++) cin >> a[i];
  sort(a.begin(), a.end());
  vector<long long> s(n);
  for (int i = int(0); i <= int(n - 1); i++) {
    sum += a[i];
    s[i] = sum;
  }
  for (int i = int(0); i <= int(n - 1); i++) {
    if (s[i] <= x)
      ans++;
    else
      break;
  }
  if (ans == n) ans = n - 1;
  cout << ans;
  return 0;
}
