#include <bits/stdc++.h>
using namespace std;
int val[1005];
int a[1005];
int h;
int cmp(int x, int y) { return x > y; }
int is(int x) {
  for (int i = 1; i <= x; i++) {
    a[i] = val[i];
  }
  sort(a + 1, a + x + 1, cmp);
  long long sum = 0;
  for (int i = 1; i <= x; i += 2) {
    sum += a[i];
  }
  if (sum <= h)
    return 1;
  else
    return 0;
}
int main() {
  int n;
  cin >> n >> h;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &val[i]);
  }
  int l = 1, r = n;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (is(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << l - 1 << endl;
  return 0;
}
