#include <bits/stdc++.h>
using namespace std;
int n, h;
int a[1010];
bool check(int k, int height) {
  vector<int> c;
  for (int i = 1; i <= k; i++) c.push_back(a[i]);
  if (c.size() % 2) c.push_back(0);
  sort(c.begin(), c.end());
  long long fuck = 0;
  for (int i = 0; i < c.size(); i += 2) fuck += (long long)max(c[i], c[i + 1]);
  return fuck <= height;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> h;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int l = 1, r = n;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (check(mid, h))
      l = mid;
    else
      r = mid - 1;
  }
  cout << l << endl;
  return 0;
}
