#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, x;
  cin >> n >> x;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int res = 0;
  for (int i = 0; i < n; i++) {
    res += a[i];
  }
  if (res == x) {
    cout << n << endl;
    return 0;
  }
  int ans = 0;
  ll sum = 0;
  for (int i = 0; i < n - 1; i++) {
    sum += a[i];
    if (sum > x) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
