#include <bits/stdc++.h>
using namespace std;
int n, h, a[1005], ans, t[1005];
inline int read() {
  int ret = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -ff;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = (ret << 3) + (ret << 1) + (ch ^ 48);
    ch = getchar();
  }
  return ret * ff;
}
inline bool check(int x) {
  long long now = 0;
  for (int i = 1; i <= x; i++) t[i] = a[i];
  sort(t + 1, t + x + 1);
  if (x & 1) {
    now += t[1];
    for (int i = 2; i <= x; i += 2) now += t[i + 1];
  } else
    for (int i = 1; i <= x; i += 2) now += t[i + 1];
  return now <= h;
}
signed main() {
  n = read(), h = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  int l = 1, r = n;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  printf("%d", ans);
  return 0;
}
