#include <bits/stdc++.h>
using namespace std;
const int MXN = 100010;
int n;
int a[MXN], k, ans;
namespace solve {
void solve() {}
}  // namespace solve
int main() {
  int ans = 0;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    if (k >= a[i] * 2 || k == a[i]) {
      k -= a[i];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
