#include <bits/stdc++.h>
int bs(int low, int high, std::function<bool(int)> testFunc) {
  while (low <= high) {
    int mid = (low + high) / 2;
    if (testFunc(mid)) {
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  return high;
}
int n, h;
int a[1005];
int ac[1005];
bool test(int amount) {
  for (int i = 0; i < amount; i++) {
    ac[i] = a[i];
  }
  std::sort(ac, ac + amount, std::greater<int>());
  long long height = 0;
  for (int i = 0; i < amount; i += 2) {
    height += ac[i];
  }
  return height <= h;
}
int main() {
  scanf("%d %d", &n, &h);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int ans = bs(0, n, test);
  printf("%d\n", ans);
  return 0;
}
