#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1000000007;
void solve() {
  int n, x;
  cin >> n >> x;
  vector<ll> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  a.push_back(2147483647);
  sort((a).begin(), (a).end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] <= x) {
      if (a[i] + a[i + 1] <= x) {
        x -= a[i];
        ans++;
      } else {
        if (a[i] == x) ans++;
        break;
      }
    } else {
      break;
    }
  }
  std::cout << (ans) << "\n";
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  cout << fixed << setprecision(12);
  solve();
}
