#include <bits/stdc++.h>
using namespace std;
long long n, h;
vector<long long> a;
bool chek(long long mid) {
  vector<long long> ans(mid + 1);
  for (int i = 0; i <= mid; ++i) {
    ans[i] = a[i];
  }
  sort(ans.begin(), ans.end());
  reverse(ans.begin(), ans.end());
  long long h1 = h;
  for (long long i = 0; i <= mid; i += 2) {
    if (i + 1 <= mid && ans[i + 1] > h1 || ans[i] > h1) {
      return false;
    }
    h1 -= ans[i];
  }
  return true;
}
int main() {
  cin >> n >> h;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long l = -1, r = n;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    if (chek(mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << l + 1;
  return 0;
}
