#include <bits/stdc++.h>
using namespace std;
int n, h, k;
int a[1005];
int temp;
bool is_possible(int k) {
  if (k == 1) return true;
  if (k > n) return false;
  vector<int> v(a + 1, a + k + 1);
  sort(v.begin(), v.end());
  int req_h = 0;
  bool process = true;
  for (auto it = v.rbegin(); it != v.rend(); it++) {
    if (process) {
      req_h += *it;
      process = false;
    } else
      process = true;
    if (req_h > h) return false;
  }
  return true;
}
int binary_search(int prev_k, int k) {
  if (is_possible(k)) {
    if (k == prev_k)
      return k;
    else if (abs(k - prev_k) == 1) {
      if (is_possible(max(k, prev_k)))
        return max(k, prev_k);
      else if (is_possible(min(k, prev_k)))
        return min(k, prev_k);
    } else {
      return binary_search(k, k + ceil(abs(k - prev_k) / 2.0));
    }
  } else {
    if (k == prev_k)
      return binary_search(k, k / 2);
    else
      return binary_search(k, k - floor(abs(k - prev_k)) / 2.0);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> h;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cout << binary_search(n, n);
  return 0;
}
