#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
long long a[N], b[N];
long long n, h;
bool cmp(int a, int b) { return a > b; }
long long judge(int index) {
  for (int i = 0; i <= index; i++) {
    b[i] = a[i];
  }
  sort(b, b + index + 1, cmp);
  long long sum;
  if (index % 2 == 0)
    sum = b[index], index--;
  else
    sum = 0;
  for (int i = 0; i <= index; i += 2) {
    sum += b[i];
  }
  if (sum <= h)
    return 1;
  else
    return 0;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> h;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int l = 0, r = n - 1;
  long long res;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (judge(mid)) {
      l = mid + 1;
      res = mid;
    } else {
      r = mid - 1;
    }
  }
  cout << res + 1 << "\n";
  return 0;
}
