#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:367772116")
using namespace std;
long long n, h;
vector<long long> v;
bool func(int len) {
  vector<long long> v2 = v;
  sort(v2.begin(), v2.begin() + len);
  long long ost = h;
  for (int i = len - 1; i >= 0; i -= 2) {
    ost -= v2[i];
  }
  if (ost < 0)
    return false;
  else
    return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> h;
  v.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> v[i];
  }
  int l = 0;
  int r = n + 1;
  while (r - l > 1) {
    int m = l + r >> 1;
    if (func(m))
      l = m;
    else
      r = m;
  }
  cout << l;
}
