#include <bits/stdc++.h>
using namespace std;
int H;
int h[1001];
bool can(int n) {
  sort(h, h + n);
  reverse(h, h + n);
  long long ch = 0;
  for (int i = 0; i < n; i += 2) {
    ch += h[i];
  }
  return ch <= (long long)H;
}
int main() {
  srand(31415);
  ios::sync_with_stdio(0);
  int n, max_can = -1;
  cin >> n >> H;
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
    if (can(i + 1)) {
      max_can = i + 1;
    }
  }
  cout << max_can << "\n";
  return 0;
}
