#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  ll a[112345], b;
  cin >> n >> b;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  ll ans = 0;
  for (int i = 0; i < n; i++)
    if (b >= a[i]) b -= a[i], ans++;
  if (b > 0) ans--;
  cout << ans << endl;
  return 0;
}
