#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, h;
  cin >> n >> h;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  int l = 1, r = n + 1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    vector<int> b;
    for (int i = 0; i < m; ++i) b.push_back(a[i]);
    sort((b).begin(), (b).end());
    long long curH = 0;
    for (int i = m - 1; i >= 0; i -= 2) curH += max(b[i], (i ? b[i - 1] : 0));
    if (curH <= h)
      l = m;
    else
      r = m;
  }
  cout << l;
}
