#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int h;
bool cani(int k, int H) {
  vector<int> b(k);
  for (int i = 0; i < (k); ++i) {
    b[i] = a[i];
  }
  int HH = H;
  sort(b.begin(), b.end());
  int i = 0;
  while (i < k and b[i] <= H) {
    if (i + 1 < k and b[i + 1] <= H) {
      H -= b[i + 1];
      i += 2;
    } else {
      i++;
      break;
    }
  }
  if (i == k) {
    return true;
  }
  i = 1;
  H = HH - b[0];
  if (H < 0) return false;
  while (i < k and b[i] <= H) {
    if (i + 1 < k and b[i + 1] <= H) {
      H -= b[i + 1];
      i += 2;
    } else {
      i++;
      break;
    }
  }
  return (i == k);
}
int main() {
  int(n);
  scanf("%d", &n);
  scanf("%d", &(h));
  a = vector<int>(n);
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &(a[i]));
  }
  int tt = 0;
  int k = 1024;
  while (k) {
    if (tt + k <= n and cani(tt + k, h)) tt += k;
    k >>= 1;
  }
  printf("%d\n", tt);
}
