#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
const int mod = 1e9 + 9;
long long n, h, a[maxn];
long long bs(long long lo, long long hi) {
  while (lo < hi) {
    long long mid = (lo + hi + 1) / 2;
    vector<long long> tmp;
    for (long long i = 0; i < mid; i++) tmp.push_back(a[i]);
    sort(tmp.begin(), tmp.end(), greater<long long>());
    long long sum = 0;
    for (long long i = 0; i < mid; i += 2) sum += tmp[i];
    if (sum > h)
      hi = mid - 1;
    else
      lo = mid;
  }
  return lo;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> h;
  for (long long i = 0; i < n; i++) cin >> a[i];
  cout << bs(0, n) << endl;
  return 0;
}
