#include <bits/stdc++.h>
using namespace std;
using vl = vector<long long>;
using vs = vector<string>;
using vc = vector<char>;
using ll = long long;
using vvl = vector<vector<ll> >;
using vd = vector<double>;
bool is_prime(int x) {
  if (x <= 1) return false;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
ll p = 0, q = 0, r = 0;
int main() {
  ll n, x;
  cin >> n >> x;
  vl a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    p += a[i];
    if (x < p) {
      q = i;
      break;
    }
    if (i == n - 1) q = n;
  }
  cout << q << endl;
  ;
}
