#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, h;
  cin >> n >> h;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  auto check = [&](int k) {
    vector<int> tmp(vec.begin(), vec.begin() + k);
    sort(tmp.rbegin(), tmp.rend());
    int sum = 0;
    vector<bool> vis(k, false);
    for (int i = 1; i < k; i += 2) {
      vis[i] = vis[i - 1] = true;
      sum += max(tmp[i], tmp[i - 1]);
      if (sum > h) {
        return false;
      }
    }
    int pos = -1;
    for (int i = 0; i < k; i++) {
      if (!vis[i]) {
        pos = i;
        break;
      }
    }
    if (pos == -1) {
      return true;
    }
    for (int i = pos + 1; i < k; i++) {
      if (!vis[i]) {
        return false;
      }
    }
    sum += tmp[pos];
    if (sum > h) {
      return false;
    }
    return true;
  };
  int low = 1, high = n;
  int res = 1;
  while (low <= high) {
    int mid = (low + high) >> 1;
    if (check(mid)) {
      res = max(res, mid);
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  cout << res << '\n';
  return 0;
}
