#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
const int mod = 1e9 + 7;
int a[N], b[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int l = 0, r = n, mid, ans;
  while (l <= r) {
    mid = (l + r) >> 1;
    memcpy(b, a, sizeof(a));
    sort(b + 1, b + 1 + mid);
    long long height = 0;
    for (int i = mid; i > 0; i -= 2) height += b[i];
    if (height <= m)
      l = mid + 1, ans = mid;
    else
      r = mid - 1;
  }
  printf("%d\n", ans);
  return 0;
}
