#include <bits/stdc++.h>
using namespace std;
int n;
long long h;
int a[1003];
int aclone[1003];
void nhap() {
  cin >> n >> h;
  for (int i = 1; i <= n; i++) cin >> a[i];
}
bool check(int mid) {
  for (int i = 1; i <= mid; i++) aclone[i] = a[i];
  sort(aclone + 1, aclone + mid + 1);
  long long temp = 0;
  for (int i = mid; i >= 1; i -= 2) {
    temp = temp + aclone[i];
  }
  return temp <= h;
}
void xuli() {
  int l = 0, r = n + 1;
  while (r - l > 1) {
    int mid = (r + l) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  cout << l;
}
int main(int argc, char const *argv[]) {
  nhap();
  xuli();
  return 0;
}
