#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, i;
  long long int rock(long long int*, long long int, long long int);
  long long int c, n, low, high, mid, j, ans = 0;
  cin >> n >> c;
  long long int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  low = 1;
  high = n;
  mid = (low + high) / 2;
  while (low <= high) {
    j = rock(a, c, mid);
    if (j == 1) {
      ans = mid;
      low = mid + 1;
    } else
      high = mid - 1;
    mid = (high + low) / 2;
  }
  cout << ans << "\n";
  return 0;
}
long long int rock(long long int a[], long long int c, long long int mid) {
  long long int count = 0, i, p;
  long long int b[mid];
  for (i = 0; i < mid; i++) {
    b[i] = a[i];
  }
  sort(b, b + mid);
  for (i = mid - 1; i >= 0; i = i - 2) {
    count = count + b[i];
    if (count > c) break;
  }
  if (count <= c)
    return 1;
  else
    return 0;
}
