#include <bits/stdc++.h>
using namespace std;
int a[1005], t[1005], h;
inline bool check(int k) {
  int i, now = 0;
  for (i = 1; i <= k; ++i) t[i] = a[i];
  sort(t + 1, t + k + 1);
  for (i = k; i > 1; i -= 2) {
    now += t[i];
    if (now > h) return 0;
  }
  if (i == 1 && now + t[1] > h) return 0;
  return 1;
}
int main() {
  int n, i, l = 1, r, m;
  scanf("%d%d", &n, &h);
  for (i = 1; i <= n; ++i) scanf("%d", a + i);
  r = n;
  while (l < r) {
    m = l + r + 1 >> 1;
    if (check(m))
      l = m;
    else
      r = m - 1;
  }
  printf("%d", l);
  return 0;
}
