#include <bits/stdc++.h>
using namespace std;
long long int arr[10000];
long long int n, h;
bool ok(long long int k) {
  vector<int> temp(k);
  for (int i = 1; i <= k; i++) temp[i - 1] = arr[i];
  sort(temp.rbegin(), temp.rend());
  long long int Z = h;
  for (int i = 0; i < temp.size();) {
    if (i + 1 < temp.size()) {
      if (temp[i] <= Z && temp[i + 1] <= Z) {
        Z -= max(temp[i], temp[i + 1]);
        i += 2;
      } else
        return false;
    } else {
      if (temp[i] <= Z) {
        Z -= temp[i];
        i++;
      } else
        return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> h;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  long long int lo = 1, hi = n;
  long long int ans;
  while (lo <= hi) {
    long long int k = (lo + hi) / 2;
    if (ok(k)) {
      ans = k;
      lo = k + 1;
    } else {
      hi = k - 1;
    }
  }
  cout << ans << endl;
}
