#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 8;
const int MAXN = 5e7 + 1;
const int BITMAX = 18;
const int INF = 1e9 + 2;
const long long LLINF = 1e17 + 3;
const int MOD = 1e9 + 7;
const long double Pi = acos(-1);
int n, h;
int a[MAX];
int mx[MAX];
vector<int> v;
bool chk(int x) {
  v.clear();
  for (int i = 0; i < x; ++i) v.push_back(a[i]);
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  bool lst = 0;
  int tall = h;
  for (int i = 0; i < v.size(); ++i) {
    int cur = v[i];
    if (lst)
      lst = 0;
    else if (cur > tall)
      return 0;
    else
      tall -= cur, lst = 1;
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  scanf("%d", &h);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  int st = 1, en = n;
  int res = -1;
  while (st <= en) {
    int md = (st + en) >> 1;
    if (chk(md))
      st = md + 1, res = md;
    else
      en = md - 1;
  }
  printf("%d\n", res);
  return 0;
}
