#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int maxn = 3e5 + 10;
const int maxm = 1e6 + 10;
const long long mod = 998244353;
int a[maxn], b[maxn];
bool judge(int mid, int h) {
  int temph = h;
  for (int i = 0; i < mid; i++) b[i] = a[i];
  sort(b, b + mid);
  int ans = 0;
  for (int i = 0; i < mid; i += 2) {
    if (b[i] <= h) ans++;
    if (i + 1 < mid && b[i + 1] <= h) ans++;
    if (i == mid - 1)
      h -= b[i];
    else
      h -= b[i + 1];
    if (h <= 0) break;
  }
  if (ans >= mid) return true;
  ans = 0, h = temph;
  for (int i = mid - 1; i >= 0; i -= 2) {
    if (b[i] <= h) ans++;
    if (i - 1 >= 0 && b[i - 1] <= h) ans++;
    h -= b[i];
    if (h <= 0) break;
  }
  return ans >= mid;
}
int main() {
  int n, h;
  cin >> n >> h;
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 1;
  int l = 1, r = n;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (judge(mid, h))
      l = mid + 1, ans = mid;
    else
      r = mid - 1;
  }
  cout << ans << endl;
  return 0;
}
