#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  x *= f;
}
int N, K, ans = 0;
int h[10005], s[10005];
bool cmp(int x, int y) { return x > y; }
bool check(int n) {
  int k = K;
  ans = 0;
  for (int i = 0; i < n; ++i) h[i] = s[i];
  sort(h, h + n, cmp);
  int p = 0;
  int dh;
  while (p < n) {
    if (p & 1) {
      dh = 0;
    } else
      dh = h[p];
    if (dh <= k) {
      k -= dh;
      ++ans;
    } else
      break;
    ++p;
  }
  return ans == n;
}
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; ++i) read(s[i]);
  int l = 0, r = N + 1;
  while (l < r - 1) {
    int mid = (l + r) >> 1;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  cout << l << endl;
  return 0;
}
