#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, h;
  cin >> n >> h;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    std::cin >> arr[i];
  }
  long long start = 0;
  long long end = n - 1;
  long long mid = 0;
  while (start <= end) {
    mid = (start + end + 1) / 2;
    long long s[mid + 1];
    copy(arr, arr + mid + 1, s);
    sort(s, s + mid + 1);
    long long k = h;
    for (long long i = mid; i >= 0; i -= 2) {
      k -= s[i];
    }
    if (k >= 0) {
      start = mid + 1;
    } else {
      end = mid - 1;
    }
  }
  cout << end + 1 << "\n";
  return 0;
}
