#include <bits/stdc++.h>
using namespace std;
typedef unsigned int UI;
typedef long int LI;
typedef unsigned long int ULI;
typedef long long int LL;
typedef unsigned long long int ULL;
const LL MOD = 1e9 + 7;
inline int scanInt() {
  int n = 0;
  char ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = (n << 1) + (n << 3) + (int)(ch - '0');
    ch = getchar();
  }
  return n * sign;
}
inline LL scanLong() {
  LL n = 0;
  char ch = getchar();
  LL sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = (n << 1) + (n << 3) + (LL)(ch - '0');
    ch = getchar();
  }
  return n * sign;
}
int main() {
  LL n = scanLong();
  ;
  LL h = scanLong();
  ;
  LL bottles[n];
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    bottles[i] = scanLong();
  LL lo = 1, hi = n;
  while (lo < hi) {
    LL mid = (lo + hi + 1) >> 1;
    priority_queue<LL> pq;
    for (__typeof(mid) i = (0) - ((0) > (mid)); i != (mid) - ((0) > (mid));
         i += 1 - 2 * ((0) > (mid)))
      pq.push(bottles[i]);
    LL reqH = 0;
    while (!pq.empty()) {
      reqH += pq.top();
      pq.pop();
      if (!pq.empty()) pq.pop();
    }
    if (reqH <= h)
      lo = mid;
    else
      hi = mid - 1;
  }
  printf("%lld ", lo);
  printf("\n");
}
