#include <bits/stdc++.h>
using namespace std;
const int inf = 1e6 + 10;
const long long mod = 1000000007;
const int MOST_LARGE = 0x3f3f3f3f;
long long a[inf];
int main() {
  int n;
  long long m;
  scanf("%d%I64d", &n, &m);
  int ans = 0;
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 1; i <= n; i++) {
    sort(a + 1, a + i + 1);
    long long cnt = 0;
    for (int j = i; j > 1; j -= 2) {
      cnt += max(a[j], a[j - 1]);
    }
    if (i % 2) cnt += a[1];
    if (cnt <= m)
      ans = i;
    else
      break;
  }
  printf("%d", ans);
}
