#include <bits/stdc++.h>
using namespace std;
int cmp(int a, int b) { return a > b; }
int main() {
  int n, m;
  int a[1010];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    sort(a + 1, a + i + 1, cmp);
    int sum = 0;
    int k = m;
    for (int j = 1; j <= i; j++) {
      if (j % 2 == 1) {
        k = k - a[j];
        if (k < 0) break;
        sum++;
      } else
        sum++;
    }
    mx = max(mx, sum);
  }
  cout << mx << endl;
}
