#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, h, a[1000], l = 0, r, m;
  cin >> n >> h;
  r = n + 1;
  for (int i = 0; i < n; i++) cin >> a[i];
  while (l < r - 1) {
    m = (l + r) / 2;
    vector<long long> b;
    for (int i = 0; i < m; i++) b.push_back(a[i]);
    sort(b.begin(), b.end());
    long long s = 0;
    for (int i = m - 1; i > 0; i -= 2) s += b[i];
    if (m % 2) s += b[0];
    if (s <= h)
      l = m;
    else
      r = m;
  }
  cout << l;
}
