#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long int h;
  cin >> n >> h;
  vector<long long int> arr(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> arr[i];
  int lo = 1, hi = n;
  int k = 0;
  while (lo <= hi) {
    int mid = lo + (hi - lo) / 2;
    long long int sum = 0;
    vector<long long int> alt(arr);
    sort(alt.begin() + 1, alt.begin() + mid + 1);
    for (int i = mid; i >= 1; i -= 2) {
      sum += alt[i];
    }
    if (sum <= h) {
      k = max(k, mid);
      lo = mid + 1;
    } else
      hi = mid - 1;
  }
  cout << k << endl;
  return 0;
}
