#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
long long n, h, t, a[MAXN], b[MAXN];
bool wk(int k) {
  for (int i = 0; i < k; i++) b[i] = a[i];
  sort(b, b + k);
  long long cnt = 0;
  for (int i = k - 1; i >= 0; i -= 2) cnt += b[i];
  return cnt <= h;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  while (cin >> n >> h) {
    for (int i = 0; i < n; i++) cin >> a[i];
    int l = 0, r = n, mid, ans = 0;
    while (l <= r) {
      mid = (l + r) / 2;
      if (wk(mid))
        l = mid + 1, ans = max(ans, mid);
      else
        r = mid - 1;
    }
    cout << ans << "\n";
  }
}
